次のパラメーターを期待するメソッドがあります。
public IQueryable<TEntity> GetAllIncluding(params Expression<Func<TEntity, object>>[] includeProperties)
{
foreach (var includeProperty in includeProperties)
{
dbSet.Include(includeProperty);
}
return dbSet;
}
パラメータを渡す方法は次のとおりです。
IQueryable<User> users = repo.GetAllIncluding(u => u.EmailNotices, u => u.EmailTemplatePlaceholders, u => u.Actions);
ただし、特定の条件を渡すかどうかを確認する必要があります。
たとえば、変数がある場合useEmailNotices = false
は渡したくありませんEmailNotices
が、そうであれば渡しtrue
ます。3つすべてに対してこれを行う必要があります。これを行うには長い道のりがあることは知っていますが、1行の短い方法またはパラメータービルダー関数またはその性質の何かがあることを望んでいました.