如何编写linq查询以匹配SQL,例如从选项卡中选择前100*?

Ken*_*hou 19 linq

对于Ria服务,我有一个linq查询,如:

EntityQuery<Employee> query = from e in ctx.GetEmployeeQuery()  
                      orderby e.DateCreated descending
                              select e;
Run Code Online (Sandbox Code Playgroud)

然后我想从这个查询获得前100条记录,比如SQL从Employee中选择前100名

如何编写linq查询?

小智 38

EntityQuery<Employee> query = (from e in ctx.GetEmployeeQuery()  
                              orderby e.DateCreated descending
                              select e).Take (100);
Run Code Online (Sandbox Code Playgroud)

  • 对于最终的信誉,衬衫需要有一个linq声明,返回"我爱LINQ". (2认同)