public static IQueryable <TEntity> DefaultWhere <TEntity>(this IQueryable <TEntity> set, string search = null) where TEntity : class { return(IDNameObjectManager <TEntity> .ApplyWhere(set, (search == null)?null : IDNameObjectManager <TEntity> .GetNameSearchPredicate(search))); }
public static IQueryable <TEntity> DefaultWhere <TEntity>(this IQueryable <TEntity> set, IList ids) where TEntity : class { return(IDNameObjectManager <TEntity> .ApplyWhere(set, IDNameObjectManager <TEntity> .GetIDsInListPredicate(ids))); }
// TODO: AsIDs and ToIDList for IEnumerable<TEntity> // Problem: LINQ can't cast int as object // Possible solution: call the Queryable.Select via reflection with actual type of ID property // ...or like it is done in ApplyOrderBy method (un-Convert) /* * public static IQueryable<object> AsIDs<TEntity>(this IQueryable<TEntity> list) * where TEntity : class * { * return Queryable.Select(list, IDNameObjectType<TEntity>.IDSelectorExpression); * } * * public static IList ToIDList<TEntity>(this IQueryable<TEntity> list) * where TEntity : class * { * return Enumerable.ToList(list.AsIDs()); * } */ // IQueryable methods public static IQueryable <TEntity> WhereID <TEntity>(this IQueryable <TEntity> set, object id) where TEntity : class { return(IDNameObjectManager <TEntity> .ApplyWhere(set, IDNameObjectManager <TEntity> .GetIDEqualsPredicate(id))); }