How to setup SPGenesis.Entities mapping for lookup fields?

Feb 20, 2013 at 1:36 PM
I have the code below. It builds ok, but when I try to create a 'child' entity, I get the error

Could not get property 'Id' on entity 'FC.HR.DataImport.Lists.ColumnConfig'. Message: Operation could destabilize the runtime.
    public class ColumnValidatorConfig
    {
        public int Id { get; set; }
        public string Title { get; set; }
        public ValidatorTypeEnum ValidatorType { get; set; }
        public ColumnConfig Parent { get; set; }
        public string ValidatorParamaters { get; set; }
        public string ErrorMessageTemplate { get; set; }
        public string Description { get; set; }

        public DateTime Created { get; set; }

        public enum ValidatorTypeEnum
        {
            NotSpecified = 0,
            CannotBeEmpty = 1,
            RegularExperssion = 2,
            Numeric = 4,
            MaximumLength = 8,
            ExistsInSelectList = 16
        }
    }

    public class ColumnValidatorConfigMapper : SPGENEntityMap<ColumnValidatorConfig>
    {
        protected override void InitializeMapper()
        {
            RegisterIdentifierProperty(c => c.Id);

            MapField(c => c.Title, "Title");
            MapField(c => c.Description, "Description");
            MapField(c => c.ValidatorParamaters, ValidatorParamatersField.InternalName);
            MapField(c => c.ErrorMessageTemplate, ErrorMessageTemplateField.InternalName);
            MapFieldToEnum(c => c.ValidatorType, ColumnTypeField.InternalName, SPGENEntityEnumMappingOptions.ChoiceText);
            MapField(c => c.Created, "Created");
            MapLookupField(c => c.Parent.Id, ColumnConfigLookupField.InternalName);
        }
    }
Part that throws the error:
            var rep = new ColumnConfigRepository(web);
            var parent = rep.Create(new ColumnConfig()
                {
                    ColumnName = "Test",
                    ExportSortOrder = 1,
                    ColumnType = ColumnConfig.ColumnTypeEnum.Text,
                    IncludeInExport = true,
                    IsColumnRequired = true
                });

            var repChild = new ColumnValidatorConfigRepository(web);
            var child =
                repChild.Create(new ColumnValidatorConfig()
                    {
                        Description = "Desc",
                        ErrorMessageTemplate = "ErrorTemp",
                        Parent = parent,
                        Title = "Title",
                        ValidatorParamaters = "Valparams",
                        ValidatorType = ColumnValidatorConfig.ValidatorTypeEnum.CannotBeEmpty
                    });