/// <summary> /// 一对多映射 /// </summary> /// <typeparam name="TTargetEntity"></typeparam> /// <typeparam name="TKey"></typeparam> /// <param name="navigationPropertyExpression"></param> /// <param name="foreignKeyExpression"></param> /// <param name="navigationCollectionPropertyExpression"></param> /// <param name="willCascadeOnDelete"></param> /// <param name="required"></param> protected virtual void OneToManyMap <TTargetEntity, TKey>(Expression <Func <TEntity, TTargetEntity> > navigationPropertyExpression, Expression <Func <TEntity, TKey> > foreignKeyExpression, Expression <Func <TTargetEntity, ICollection <TEntity> > > navigationCollectionPropertyExpression = null, bool willCascadeOnDelete = true, bool required = true) where TTargetEntity : class { Guard.ArgumentNotNull(() => navigationPropertyExpression); Guard.ArgumentNotNull(() => foreignKeyExpression); dynamic t = null; if (required) { t = this.HasRequired(navigationPropertyExpression); } else { t = this.HasOptional(navigationPropertyExpression); } DependentNavigationPropertyConfiguration <TEntity> dependentNavigationPropertyConfiguration = null; if (navigationCollectionPropertyExpression == null) { dependentNavigationPropertyConfiguration = t.WithMany(); } else { dependentNavigationPropertyConfiguration = t.WithMany(navigationCollectionPropertyExpression); } dependentNavigationPropertyConfiguration.HasForeignKey(foreignKeyExpression).WillCascadeOnDelete(willCascadeOnDelete); }
public DependentNavigationPropertyConfigurationWrapper(DependentNavigationPropertyConfiguration <TEntity> dependentNavigationPropertyConfiguration) { this.dependentNavigationPropertyConfiguration = dependentNavigationPropertyConfiguration; }