context.table.Where(x => projectId == null || x.ProjectId == projectId) (This actually doesnt even add a WHERE TRUE to the generated SQL Query
).OptionalWhere(x => x.ProjectId, projectId) but I cant find the correct syntax for the extension method.