Entity Framework & LINQ Lambda 方法

Entity Framework & LINQ Lambda 方法

 
   Recommend :
 
   It is recommend to create Stored Procedure with Parameter on SQL Server with Entity Framework
   instead of generating the complicated SQL to LINQ.
 
   Based on this, the Development ( LINQ Query ) would be simplified.
   There is the Native SQL from Stored Procedure under SQL Server.
   The Query Performance would also be better.
 
 
   LINQ Dynamic – Where ( Filtering )
 
   this.entities.Inventories.Where("System = \"Server\" AND Equipment = \"Blade\"").Select(
      item => new {
         Model = item.Model,
         Equipment = item.Equipment,
         System = item.System,
         Status = item.Status
      }).ToList();
 
 
   LINQ Dynamic – OrderBy ( Sorting )
 
   this.entities.Inventories.OrderBy("Status ASC, Model ASC").Select(
      item => new {
         Model = item.Model,
         Equipment = item.Equipment,
         System = item.System,
         Status = item.Status
      }).ToList();
 
 
   LINQ – Skip & Take ( for Paging )
 
   this.entities.Inventories.Skip((Page – 1) * PageSize).Take(PageSize).ToList();