How to write dynamic where clause for join range varible

前端 未结 3 640
感动是毒
感动是毒 2021-01-16 13:46

I‘ve been working on a query using LINQ but I’ve run into a snag with a dynamic where clause. I want to check for a condition and if true then add that where to my query.

3条回答
  •  情歌与酒
    2021-01-16 14:24

    Use IQueryable here is more info why link

    IQueryable<{CreateNewSelectObjects}> query = ... ;
    if (sProjType != null)
    {
        query = query.Where(x => x.TypeDesc==sProjType);
    }
    

提交回复
热议问题