Tuesday, November 15, 2022

select and where query difference LINQ ASP.NET C# - with model or entity

 Select is mapping, we want to select two columns from five. (select columns) gives all rows

where will select all the columns but gives the rows with that values. (select rows) gives all columns


example:-

var employee = _db.EMPLOYEEs
    .Where(x => x.EMAIL == givenInfo || x.USER_NAME == givenInfo)
    .Select(x => new { x.EMAIL, x.ID });
reference:-https://stackoverflow.com/questions/6772267/linq-syntax-selecting-multiple-columns


 Where ~= Filter


select  = map the selected column



select for columns     and where for rows.

No comments:

Post a Comment