protected virtual CompositeIdentityPart <T> KeyProperty(Member property, string columnName, Action <KeyPropertyPart> customMapping)
        {
            var key = new KeyPropertyMapping
            {
                Name = property.Name,
                Type = new TypeReference(property.PropertyType),
                ContainingEntityType = typeof(T)
            };

            if (customMapping != null)
            {
                var part = new KeyPropertyPart(key);
                customMapping(part);
            }

            if (!string.IsNullOrEmpty(columnName))
            {
                key.AddColumn(new ColumnMapping {
                    Name = columnName
                });
            }

            keyProperties.Add(key);

            return(this);
        }
        protected virtual CompositeIdentityPart <T> KeyProperty(Member member, string columnName, Action <KeyPropertyPart> customMapping)
        {
            var type = member.PropertyType;

            if (type.IsEnum)
            {
                type = typeof(GenericEnumMapper <>).MakeGenericType(type);
            }

            var key = new KeyPropertyMapping
            {
                ContainingEntityType = typeof(T)
            };

            key.Set(x => x.Name, Layer.Defaults, member.Name);
            key.Set(x => x.Type, Layer.Defaults, new TypeReference(type));

            if (customMapping != null)
            {
                var part = new KeyPropertyPart(key);
                customMapping(part);
            }

            if (!string.IsNullOrEmpty(columnName))
            {
                var columnMapping = new ColumnMapping();
                columnMapping.Set(x => x.Name, Layer.Defaults, columnName);
                key.AddColumn(columnMapping);
            }

            keys.Add(key);

            return(this);
        }
 public void WhenKeyPropertyMappingContainsLengthAndCustomColumnLengthAttributeIsRenderedIntoColumnElement()
 {
     var keyPropertyMapping = new KeyPropertyMapping();
     keyPropertyMapping.Set(propertyMapping => propertyMapping.Length, Layer.Defaults, 2);
     keyPropertyMapping.AddColumn(new ColumnMapping());
     writer.VerifyXml(keyPropertyMapping).DoesntHaveAttribute("length").Element("column").HasAttribute("length", "2");
 }
Ejemplo n.º 4
0
        public override void ProcessKeyProperty(KeyPropertyMapping mapping)
        {
            var conventions = finder.Find <IKeyPropertyConvention>();

            Apply <IKeyPropertyInspector, IKeyPropertyInstance>(conventions,
                                                                new KeyPropertyInstance(mapping));
        }
        public override void Visit(KeyPropertyMapping propertyMapping)
        {
            var writer = serviceLocator.GetWriter <KeyPropertyMapping>();
            var xml    = writer.Write(propertyMapping);

            document.ImportAndAppendChild(xml);
        }
        KeyPropertyPart Map(Member member, string columnName)
        {
            var type = member.PropertyType;

            if (type.IsEnum)
            {
                type = typeof(GenericEnumMapper <>).MakeGenericType(type);
            }

            var property = new KeyPropertyMapping
            {
                Name = member.Name,
                Type = new TypeReference(type),
                ContainingEntityType = typeof(T)
            };

            if (!string.IsNullOrEmpty(columnName))
            {
                property.AddColumn(new ColumnMapping {
                    Name = columnName
                });
            }

            mapping.AddProperty(property);

            return(new KeyPropertyPart(property));
        }
Ejemplo n.º 7
0
        public void WhenKeyPropertyMappingContainsLengthAndCustomColumnLengthAttributeIsRenderedIntoColumnElement()
        {
            var keyPropertyMapping = new KeyPropertyMapping();

            keyPropertyMapping.Set(propertyMapping => propertyMapping.Length, Layer.Defaults, 2);
            keyPropertyMapping.AddColumn(new ColumnMapping());
            writer.VerifyXml(keyPropertyMapping).DoesntHaveAttribute("length").Element("column").HasAttribute("length", "2");
        }
        public void ShouldWriteColumns()
        {
            var mapping = new KeyPropertyMapping();

            mapping.AddColumn(new ColumnMapping());

            writer.VerifyXml(mapping)
                .Element("column").Exists();
        }
Ejemplo n.º 9
0
        public void ShouldWriteColumns()
        {
            var mapping = new KeyPropertyMapping();

            mapping.AddColumn(new ColumnMapping());

            writer.VerifyXml(mapping)
            .Element("column").Exists();
        }
Ejemplo n.º 10
0
 public void SetUp()
 {
     this.mapping = new KeyPropertyMapping();
     this.part    = new KeyPropertyPart(mapping);
 }
 public override void Visit(KeyPropertyMapping mapping)
 {
     mapping.AcceptVisitor(this);
 }
Ejemplo n.º 12
0
 public KeyPropertyPart(KeyPropertyMapping mapping)
 {
     this.mapping = mapping;
     Access = new AccessStrategyBuilder<KeyPropertyPart>(this, value => mapping.Set(x =>x.Access, Layer.UserSupplied, value));
 }
Ejemplo n.º 13
0
 public virtual void Visit(KeyPropertyMapping mapping)
 {
 }
Ejemplo n.º 14
0
 public KeyPropertyInspector(KeyPropertyMapping mapping)
 {
     this.mapping = mapping;
 }
Ejemplo n.º 15
0
 public void CreateDsl()
 {
     mapping   = new KeyPropertyMapping();
     inspector = new KeyPropertyInspector(mapping);
 }
Ejemplo n.º 16
0
 public KeyPropertyPart(KeyPropertyMapping mapping)
 {
     this.mapping = mapping;
     Access       = new AccessStrategyBuilder <KeyPropertyPart>(this, value => mapping.Access = value);
 }
 public virtual void ProcessKeyProperty(KeyPropertyMapping mapping)
 {
 }
 public override void Visit(KeyPropertyMapping mapping)
 {
     mapping.AcceptVisitor(this);
 }
Ejemplo n.º 19
0
 public KeyPropertyPart(KeyPropertyMapping mapping)
 {
     this.mapping = mapping;
     Access       = new AccessStrategyBuilder <KeyPropertyPart>(this, value => mapping.Set(x => x.Access, Layer.UserSupplied, value));
 }
Ejemplo n.º 20
0
 public KeyPropertyPart(KeyPropertyMapping mapping)
 {
     this.mapping = mapping;
     Access = new AccessStrategyBuilder<KeyPropertyPart>(this, value => mapping.Access = value);
 }
 public void CreateDsl()
 {
     mapping = new KeyPropertyMapping();
     inspector = new KeyPropertyInspector(mapping);
 }
Ejemplo n.º 22
0
 private static KeyPropertyMapping GetKeyPropertyMapping(Type entityType, string name, Type type)
 {
     var keyPropertyMapping = new KeyPropertyMapping {ContainingEntityType = entityType};
     keyPropertyMapping.Set(x => x.Name, Layer.Defaults, name);
     keyPropertyMapping.Set(x => x.Type, Layer.Defaults, new TypeReference(type));
     var columnMapping = new ColumnMapping();
     columnMapping.Set(x => x.Name, Layer.Defaults, name);
     keyPropertyMapping.AddColumn(columnMapping);
     return keyPropertyMapping;
 }
 public KeyPropertyInspector(KeyPropertyMapping mapping)
 {
     this.mapping = mapping;
 }
Ejemplo n.º 24
0
 public virtual void ProcessKeyProperty(KeyPropertyMapping mapping)
 {
 }
 public KeyPropertyInstance(KeyPropertyMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
 }
 public void AddProperty(KeyPropertyMapping property)
 {
     properties.Add(property);
 }
 public virtual void Visit(KeyPropertyMapping mapping)
 {
 }
 public void SetUp()
 {
     this.mapping = new KeyPropertyMapping();
     this.part = new KeyPropertyPart(mapping);
 }
Ejemplo n.º 29
0
 public KeyPropertyInstance(KeyPropertyMapping mapping)
     : base(mapping)
 {
     this.mapping = mapping;
 }
Ejemplo n.º 30
0
 public KeyPropertyPart(KeyPropertyMapping mapping)
 {
     this.mapping = mapping;
 }