public NavigationPropertyBindingConfiguration HasSingletonBinding <TTargetType, TDerivedEntityType>( Expression <Func <TDerivedEntityType, TTargetType> > navigationExpression, NavigationSourceConfiguration <TTargetType> targetSingleton) where TTargetType : class where TDerivedEntityType : class, TEntityType { if (navigationExpression == null) { throw Error.ArgumentNull("navigationExpression"); } if (targetSingleton == null) { throw Error.ArgumentNull("targetSingleton"); } EntityTypeConfiguration <TDerivedEntityType> derivedEntityType = _modelBuilder.EntityType <TDerivedEntityType>().DerivesFrom <TEntityType>(); NavigationPropertyConfiguration navigation = derivedEntityType.HasRequired(navigationExpression); IList <MemberInfo> bindingPath = new List <MemberInfo> { TypeHelper.AsMemberInfo(typeof(TDerivedEntityType)), navigation.PropertyInfo }; return(this.Configuration.AddBinding(navigation, targetSingleton.Configuration, bindingPath)); }
public NavigationPropertyBindingConfiguration HasRequiredBinding <TTargetType, TDerivedEntityType>( Expression <Func <TDerivedEntityType, 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.HasRequired(navigationExpression); IList <MemberInfo> bindingPath = new List <MemberInfo> { TypeHelper.AsMemberInfo(typeof(TDerivedEntityType)), navigation.PropertyInfo }; return(this.Configuration.AddBinding(navigation, _modelBuilder.EntitySet <TTargetType>(entitySetName).Configuration, bindingPath)); }