I have method that expects the following parameters:
public IQueryable<TEntity> GetAllIncluding(params Expression<Func<TEntity, object>>[] includeProperties)
{
foreach (var includeProperty in includeProperties)
{
dbSet.Include(includeProperty);
}
return dbSet;
}
Here's how I pass in my params:
IQueryable<User> users = repo.GetAllIncluding(u => u.EmailNotices, u => u.EmailTemplatePlaceholders, u => u.Actions);
However, I need to be able to check certain conditions before I pass them in or not.
For example, if I have a variable useEmailNotices = false
, then I don't want to pass in EmailNotices
but if it's true
then I do. I need to do this for all three. I know there's a long way to do this but I was hoping that there was a one line short way or a param builder function or something of that nature.