/// <summary> /// Configures a related entity of the given entity. /// </summary> /// <typeparam name="TProperty">The type of the related entity property.</typeparam> /// <typeparam name="TKey">The type of the related entity key.</typeparam> /// <param name="relatedEntityProperty">The related entity property.</param> /// <param name="relatedEntityKey">The related entity key.</param> /// <returns>The configuration ovject of the given entity.</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="relatedEntityProperty"/> is null.</exception> /// <exception cref="System.ArgumentException">The <paramref name="relatedEntityProperty"/> is not an one level property expression.</exception> public RelatedEntityItemConfiguration <TEntity, TProperty> WithEntity <TProperty, TKey>( Expression <Func <TItem, TProperty> > relatedEntityProperty, Expression <Func <TItem, TKey> > relatedEntityKey) where TProperty : class { Error.ArgumentNullException_IfNull(relatedEntityProperty, "relatedEntityProperty"); DAError.ArgumentException_IfNotOneLevelPropertyExpression(relatedEntityProperty); if (relatedEntityKey != null) { DAError.ArgumentException_IfNotOneLevelPropertyExpression(relatedEntityKey); } var memberProperty = ReflectionHelper.GetPropertyName(relatedEntityProperty); var memberKey = relatedEntityKey != null?ReflectionHelper.GetPropertyName(relatedEntityKey) : string.Empty; var newMember = new RelatedEntityInfo( string.Format(newMemberFormat2, currentRelatedEntityInfo.RelatedPropertyPath, memberProperty), string.Format(newMemberFormat2, currentRelatedEntityInfo.RelatedKeyPath, memberKey)); if (!relatedEntityInfo.Contains(newMember)) { relatedEntityInfo.Remove(currentRelatedEntityInfo); relatedEntityInfo.Add(newMember); } return(new RelatedEntityItemConfiguration <TEntity, TProperty>( relatedEntityInfo, newMember, subEntityInfo, usedEntityInfo, usingEntityInfo)); }
/// <summary> /// Configures using entities for the entity. /// </summary> /// <typeparam name="TProperty">The type of the using entities property.</typeparam> /// <param name="usingEntitiesProperty">The using collection.</param> /// <returns>The configuration object to configure a using entities.</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="usingEntitiesProperty"/> is null.</exception> /// <exception cref="System.ArgumentException">The <paramref name="usingEntitiesProperty"/> is not an one level property expression.</exception> public RelatedEntityItemConfiguration <TEntity, TProperty> IsUsedByEntities <TProperty>( Expression <Func <TEntity, ICollection <TProperty> > > usingEntitiesProperty) where TProperty : class { Error.ArgumentNullException_IfNull(usingEntitiesProperty, "usingEntitiesProperty"); DAError.ArgumentException_IfNotOneLevelPropertyExpression(usingEntitiesProperty); var member = new RelatedEntityInfo(ReflectionHelper.GetPropertyName(usingEntitiesProperty), string.Empty); if (!usingEntityInfo.Contains(member)) { usingEntityInfo.Add(member); } return(new RelatedEntityItemConfiguration <TEntity, TProperty>( usingEntityInfo, member, subEntityInfo, usedEntityInfo, usingEntityInfo)); }
/// <summary> /// Configures a sub entity of the entity. /// </summary> /// <typeparam name="TProperty">The type of the sub entity property.</typeparam> /// <typeparam name="TKey">The type of the sub entity key.</typeparam> /// <param name="subEntityProperty">The sub entity property.</param> /// <param name="subEntityKey">The sub entity key.</param> /// <returns>The configuration object for related entities.</returns> /// <exception cref="System.ArgumentNullException">The <paramref name="subEntityProperty"/> is null.</exception> /// <exception cref="System.ArgumentException">The <paramref name="subEntityProperty"/> or /// <paramref name="subEntityKey"/> is not an one level property expression.</exception> public RelatedEntityItemConfiguration <TEntity, TProperty> HasSubEntity <TProperty, TKey>( Expression <Func <TEntity, TProperty> > subEntityProperty, Expression <Func <TEntity, TKey> > subEntityKey) where TProperty : class { Error.ArgumentNullException_IfNull(subEntityProperty, "subEntityProperty"); DAError.ArgumentException_IfNotOneLevelPropertyExpression(subEntityProperty); if (subEntityKey != null) { DAError.ArgumentException_IfNotOneLevelPropertyExpression(subEntityKey); } var member = new RelatedEntityInfo(ReflectionHelper.GetPropertyName(subEntityProperty), subEntityKey != null ? ReflectionHelper.GetPropertyName(subEntityKey) : string.Empty); if (!subEntityInfo.Contains(member)) { subEntityInfo.Add(member); } return(new RelatedEntityItemConfiguration <TEntity, TProperty>( subEntityInfo, member, subEntityInfo, usedEntityInfo, usingEntityInfo)); }