public NavigationPropertyBindingConfiguration HasManyBinding <TTargetType, TDerivedEntityType>(
            Expression <Func <TDerivedEntityType, IEnumerable <TTargetType> > > navigationExpression, string entitySetName)
            where TTargetType : class
            where TDerivedEntityType : class, TEntityType
        {
            if (navigationExpression == null)
            {
                throw Error.ArgumentNull("navigationExpression");
            }

            if (String.IsNullOrEmpty(entitySetName))
            {
                throw Error.ArgumentNullOrEmpty("entitySetName");
            }

            EntityTypeConfiguration <TDerivedEntityType> derivedEntityType =
                _modelBuilder.EntityType <TDerivedEntityType>().DerivesFrom <TEntityType>();

            NavigationPropertyConfiguration navigation = derivedEntityType.HasMany(navigationExpression);

            IList <MemberInfo> bindingPath = new List <MemberInfo>
            {
                TypeHelper.AsMemberInfo(typeof(TDerivedEntityType)),
                navigation.PropertyInfo
            };

            return(this.Configuration.AddBinding(navigation,
                                                 _modelBuilder.EntitySet <TTargetType>(entitySetName)._configuration, bindingPath));
        }
예제 #2
0
        public NavigationPropertyBindingConfiguration HasManyBinding <TTargetType, TDerivedEntityType>(
            Expression <Func <TDerivedEntityType, IEnumerable <TTargetType> > > navigationExpression, string entitySetName)
            where TTargetType : class
            where TDerivedEntityType : class, TEntityType
        {
            if (navigationExpression == null)
            {
                throw Error.ArgumentNull("navigationExpression");
            }

            if (String.IsNullOrEmpty(entitySetName))
            {
                throw Error.ArgumentNullOrEmpty("entitySetName");
            }

            EntityTypeConfiguration <TDerivedEntityType> derivedEntityType =
                _modelBuilder.EntityType <TDerivedEntityType>().DerivesFrom <TEntityType>();

            return(this.Configuration.AddBinding(derivedEntityType.HasMany(navigationExpression),
                                                 _modelBuilder.EntitySet <TTargetType>(entitySetName)._configuration));
        }
예제 #3
0
        public NavigationPropertyBindingConfiguration HasManyBinding <TTargetType, TDerivedEntityType>(
            Expression <Func <TDerivedEntityType, IEnumerable <TTargetType> > > navigationExpression,
            NavigationSourceConfiguration <TTargetType> targetEntitySet)
            where TTargetType : class
            where TDerivedEntityType : class, TEntityType
        {
            if (navigationExpression == null)
            {
                throw Error.ArgumentNull("navigationExpression");
            }

            if (targetEntitySet == null)
            {
                throw Error.ArgumentNull("targetEntitySet");
            }

            EntityTypeConfiguration <TDerivedEntityType> derivedEntityType =
                _modelBuilder.EntityType <TDerivedEntityType>().DerivesFrom <TEntityType>();

            return(this.Configuration.AddBinding(derivedEntityType.HasMany(navigationExpression), targetEntitySet.Configuration));
        }