Difference between && and where condition in entity framework query

前端 未结 3 1387
暗喜
暗喜 2020-12-10 17:05

Difference between and condition and two where condition in entity framework query

Code 1

I have using two where condition in my query

3条回答
  •  旧巷少年郎
    2020-12-10 17:23

    If you open your query in LinqPad you will see that both queries

    dbContext.Projects.Where(p=>p.ProjectId!=ProjectId).Where(p=>p.Name==Name)
    
    dbContext.Projects.Where(p=>p.ProjectId!=ProjectId && p.Name==Name);
    

    will result both in

    SELECT [...]
    FROM [...]
    WHERE p.ProjectId <> someId AND p.Name = 'something'
    

    There is no difference neither in performance nor in SQL query structure.

提交回复
热议问题