Lambda与LINQ写法对比:


 

上为Lambda

下为LINQ


  • 显示指定列
  • Students.select(u=>(new {Name=u.Sname,Address=u.Saddress}))
  • from s in Students Select new {s.Sname,s.Saddress}

 


 

  • 有条件显示指定列
  • Students.Where(s=>((s.SID<10)&&(s.Sname.Length<10)))

  .Select(s=> new{Name = s.Sname,Sdd = s.Saddress})

  • From s in Students

  Where s.SID<10&& s.Sname.Length<10

  Select new{Name = s.Sname,Sdd = s.Saddress}

 


 

  • 排序为升序
  • Students.OrderBy(s=>s.SID)
  • From s in Students

  Orderby s.SID

  Select s

 


 

  • 排序为降序
  • Students.OrderByDescending(s=>SID).Select(s=>s)

相关文章:

  • 2022-12-23
  • 2021-05-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
  • 2021-11-27
  • 2021-10-01
猜你喜欢
  • 2021-07-04
  • 2021-10-20
  • 2022-12-23
  • 2022-12-23
  • 2021-04-09
  • 2021-12-07
  • 2022-12-23
相关资源
相似解决方案