public BindingPathConfiguration<TTargetType> HasManyPath<TTargetType>(
            Expression<Func<TStructuralType, IEnumerable<TTargetType>>> pathExpression,
            bool contained)
            where TTargetType : class
        {
            if (pathExpression == null)
            {
                throw Error.ArgumentNull("pathExpression");
            }

            PropertyInfo pathProperty = PropertySelectorVisitor.GetSelectedProperty(pathExpression);

            IList<MemberInfo> bindingPath = new List<MemberInfo>(this._bindingPath);
            bindingPath.Add(pathProperty);

            StructuralTypeConfiguration<TTargetType> target;
            if (contained)
            {
                target = this._modelBuilder.EntityType<TTargetType>();
                this._structuralType.ContainsMany(pathExpression); // add a containment navigation property
            }
            else
            {
                target = this._modelBuilder.ComplexType<TTargetType>();
                this._structuralType.CollectionProperty(pathExpression); // add a collection complex property
            }

            return new BindingPathConfiguration<TTargetType>(this._modelBuilder, target, this._navigationSource, bindingPath);
        }
Ejemplo n.º 2
0
        public EntityTypeConfiguration <TEntityType> HasKey <TKey>(Expression <Func <TEntityType, TKey> > keyDefinitionExpression)
        {
            ICollection <PropertyInfo> properties = PropertySelectorVisitor.GetSelectedProperties(keyDefinitionExpression);

            foreach (PropertyInfo property in properties)
            {
                this._configuration.HasKey(property);
            }
            return(this);
        }
Ejemplo n.º 3
0
        private PrimitivePropertyConfiguration GetPrimitivePropertyConfiguration(Expression propertyExpression, bool optional)
        {
            PropertyInfo propertyInfo = PropertySelectorVisitor.GetSelectedProperty(propertyExpression);
            PrimitivePropertyConfiguration property = this._configuration.AddProperty(propertyInfo);

            if (optional)
            {
                property.IsOptional();
            }

            return(property);
        }
        public BindingPathConfiguration<TTargetType> HasSinglePath<TTargetType, TDerivedType>(
            Expression<Func<TDerivedType, TTargetType>> pathExpression,
            bool required,
            bool contained)
            where TTargetType : class
            where TDerivedType : class, TStructuralType
        {
            if (pathExpression == null)
            {
                throw Error.ArgumentNull("pathExpression");
            }

            PropertyInfo pathProperty = PropertySelectorVisitor.GetSelectedProperty(pathExpression);

            IList<MemberInfo> bindingPath = new List<MemberInfo>(this._bindingPath);
            bindingPath.Add(typeof(TDerivedType));
            bindingPath.Add(pathProperty);

            // make sure the derived type has the same type kind with the resource type.
            StructuralTypeConfiguration<TDerivedType> derivedConfiguration;
            if (this._structuralType.Configuration.Kind == EdmTypeKind.Entity)
            {
                derivedConfiguration = this._modelBuilder.EntityType<TDerivedType>().DerivesFrom<TStructuralType>();
            }
            else
            {
                derivedConfiguration = this._modelBuilder.ComplexType<TDerivedType>().DerivesFrom<TStructuralType>();
            }

            StructuralTypeConfiguration<TTargetType> target;
            if (contained)
            {
                target = this._modelBuilder.EntityType<TTargetType>();

                if (required)
                {
                    derivedConfiguration.ContainsRequired(pathExpression);
                }
                else
                {
                    derivedConfiguration.ContainsOptional(pathExpression);
                }
            }
            else
            {
                target = this._modelBuilder.ComplexType<TTargetType>();
                derivedConfiguration.ComplexProperty(pathExpression).OptionalProperty = !required;
            }

            return new BindingPathConfiguration<TTargetType>(this._modelBuilder, target, this._navigationSource, bindingPath);
        }
Ejemplo n.º 5
0
        private ComplexPropertyConfiguration GetComplexPropertyConfiguration(Expression propertyExpression, bool optional = false)
        {
            PropertyInfo propertyInfo             = PropertySelectorVisitor.GetSelectedProperty(propertyExpression);
            ComplexPropertyConfiguration property = this._configuration.AddComplexProperty(propertyInfo);

            if (optional)
            {
                property.IsOptional();
            }
            else
            {
                property.IsRequired();
            }

            return(property);
        }
        public BindingPathConfiguration<TTargetType> HasSinglePath<TTargetType>(
            Expression<Func<TStructuralType, TTargetType>> pathExpression,
            bool required,
            bool contained)
            where TTargetType : class
        {
            if (pathExpression == null)
            {
                throw Error.ArgumentNull("pathExpression");
            }

            PropertyInfo pathProperty = PropertySelectorVisitor.GetSelectedProperty(pathExpression);

            IList<MemberInfo> bindingPath = new List<MemberInfo>(this._bindingPath);
            bindingPath.Add(pathProperty);

            StructuralTypeConfiguration<TTargetType> target;
            if (contained)
            {
                target = this._modelBuilder.EntityType<TTargetType>();

                if (required)
                {
                    this._structuralType.ContainsRequired(pathExpression);
                }
                else
                {
                    this._structuralType.ContainsOptional(pathExpression);
                }
            }
            else
            {
                target = this._modelBuilder.ComplexType<TTargetType>();
                this._structuralType.ComplexProperty(pathExpression).OptionalProperty = !required;
            }

            return new BindingPathConfiguration<TTargetType>(this._modelBuilder, target, this._navigationSource, bindingPath);
        }
Ejemplo n.º 7
0
        internal NavigationPropertyConfiguration GetOrCreateContainedNavigationProperty(Expression navigationPropertyExpression, EdmMultiplicity multiplicity)
        {
            PropertyInfo navigationProperty = PropertySelectorVisitor.GetSelectedProperty(navigationPropertyExpression);

            return(this._configuration.AddContainedNavigationProperty(navigationProperty, multiplicity));
        }
Ejemplo n.º 8
0
        public void HasDynamicProperties(Expression <Func <TStructuralType, IDictionary <string, object> > > propertyExpression)
        {
            PropertyInfo propertyInfo = PropertySelectorVisitor.GetSelectedProperty(propertyExpression);

            this._configuration.AddDynamicPropertyDictionary(propertyInfo);
        }
Ejemplo n.º 9
0
        public virtual void Ignore <TProperty>(Expression <Func <TStructuralType, TProperty> > propertyExpression)
        {
            PropertyInfo ignoredProperty = PropertySelectorVisitor.GetSelectedProperty(propertyExpression);

            this._configuration.RemoveProperty(ignoredProperty);
        }