Пример #1
0
        public IComplexPropertyBuilder <TProperty, TEntity> HasOne <TProperty>(Expression <Func <TEntity, TProperty> > property)
        {
            string propertyName = PropertyNameExtractor.Extract(property);
            IComplexPropertyBuilder <TProperty, TEntity> propertyBuilder = this.HasOne(propertyName) as IComplexPropertyBuilder <TProperty, TEntity>;

            return(propertyBuilder);
        }
Пример #2
0
        public IComplexPropertyBuilder HasOne(string property)
        {
            ComplexProperty complexProperty = this.EntityType.ComplexProperties.Where(a => a.Property.Name == property).FirstOrDefault();

            if (complexProperty == null)
            {
                PropertyInfo propertyInfo = this.GetEntityProperty(property);
                complexProperty = new ComplexProperty(propertyInfo);
                this.EntityType.ComplexProperties.Add(complexProperty);
            }

            IComplexPropertyBuilder propertyBuilder = Activator.CreateInstance(typeof(ComplexPropertyBuilder <,>).MakeGenericType(complexProperty.Property.PropertyType, typeof(TEntity)), complexProperty) as IComplexPropertyBuilder;

            return(propertyBuilder);
        }