/// <summary> /// Configures a required relationship from this entity type. /// Instances of the entity type will not be able to be saved to the database unless this relationship is specified. /// The foreign key in the database will be non-nullable. /// </summary> /// <typeparam name="TTargetEntity"> The type of the entity at the other end of the relationship. </typeparam> /// <param name="navigationPropertyExpression"> A lambda expression representing the navigation property /// for the relationship. C#: t => t.MyProperty VB.Net: Function(t) t.MyProperty </param> /// <returns> A configuration object that can be used to further configure the relationship. </returns> public RequiredNavigationPropertyConfiguration <TEntityType, TTargetEntity> HasRequired <TTargetEntity>( Expression <Func <TEntityType, TTargetEntity> > navigationPropertyExpression) where TTargetEntity : class { if (navigationPropertyExpression == null) { throw new ArgumentNullException("navigationPropertyExpression"); } var navigationProperty = ReflectionExpressions.GetPropertyInfo(navigationPropertyExpression); IRequiredNavigationPropertyConfiguration propertyConfiguration; if (!requiredAssociationsByProperty.TryGetValue(navigationProperty, out propertyConfiguration)) { propertyConfiguration = new RequiredNavigationPropertyConfiguration <TEntityType, TTargetEntity>(navigationProperty); requiredAssociationsByProperty.Add(navigationProperty, propertyConfiguration); } return((RequiredNavigationPropertyConfiguration <TEntityType, TTargetEntity>)propertyConfiguration); }
public RequiredNavigationPropertyConfigurationWrapper(RequiredNavigationPropertyConfiguration <TEntity, TTargetEntity> requiredNavigationPropertyConfiguration) { this.requiredNavigationPropertyConfiguration = requiredNavigationPropertyConfiguration; }