❔ EF Core optional where extension method
I have a lot of optional parameters for queries. Filter by this, filter by that etc.
I can do it like this
)
I would like to avoid the null check or part every time and write something like
Im trying stuff similiar to this
Func cant be translated. Expression cant be translated if I compile it. I guess because it turns into a func..
I can do it like this
context.table.Where(x => projectId == null || x.ProjectId == projectId) (This actually doesnt even add a WHERE TRUE to the generated SQL Query
)I would like to avoid the null check or part every time and write something like
.OptionalWhere(x => x.ProjectId, projectId) but I cant find the correct syntax for the extension method.Im trying stuff similiar to this
Func cant be translated. Expression cant be translated if I compile it. I guess because it turns into a func..