/// <summary> /// Adds a request filter that includes entities where the provided collection /// contains the entity's entityValue: /// ie: Where(entity => collection.Contains(entity.entityValue)) /// </summary> /// <param name="condition">If condition is supplied, then the filter will only be applied when condition evaluates to true</param> public static TBuilder AddContainsFilter <TBuilder, TRequest, TEntity, TItem>( this RequestEntityConfigBuilderCommon <TRequest, TEntity, TBuilder> config, ICollection <TItem> collection, Expression <Func <TEntity, TItem> > entityValue, Func <TRequest, bool> condition = null) where TEntity : class where TBuilder : RequestEntityConfigBuilderCommon <TRequest, TEntity, TBuilder> => config.AddContainsFilter(x => collection, entityValue, condition);
/// <summary> /// Adds a request filter that includes entities where the provided collection /// contains the entity's entityValueMember: /// ie: Where(entity => collection.Contains(entity.entityValueMember)) /// </summary> /// <param name="condition">If condition is supplied, then the filter will only be applied when condition evaluates to true</param> public static TBuilder AddContainsFilter <TBuilder, TRequest, TEntity, TItem>( this RequestEntityConfigBuilderCommon <TRequest, TEntity, TBuilder> config, ICollection <TItem> collection, string entityValueMember, Func <TRequest, bool> condition = null) where TEntity : class where TBuilder : RequestEntityConfigBuilderCommon <TRequest, TEntity, TBuilder> { var eParamExpr = Expression.Parameter(typeof(TEntity), "e"); var body = Expression.PropertyOrField(eParamExpr, entityValueMember); var entityValue = Expression.Lambda <Func <TEntity, TItem> >(body, eParamExpr); return(config.AddContainsFilter(x => collection, entityValue, condition)); }