比如说我们要从用户表customer和用户订单表orders中,查询上海的用户,在最近10个月中至少消费3笔满10快钱的用户的姓名和年龄。如果写成传统的方法,不知道要写多少代码,而且各种复杂的处理逻辑
16lz
2021-01-22
var results = from customer in customers where customer.State == "WA" let custOrders = (from order in orders where customer.ID == order.ID select new { order.Date, order.Amount }) where custOrders.Count(co => co.Amount >= 10 && co.Date >= DateTime.Now.AddMonths(−10)) >= 3 select new { customer.Name, customer.Age };
下面另附上一条分页的linq语句:
var productList=(from prod in db.Products
where prod.Type="零食" orderby prod.datatime select u).Skip(PageSize*(PageNum-1)).Take(PageSize);
更多相关文章
- 分享一些高效的LINQ语句代码
- C#如何使用键值对取代Switch...Case语句的示例
- 第五章C++:语句的相关介绍
- Microsoft C++ 语言扩展:try-except 语句结构化异常
- C ++中continue和break语句的简单比较
- C ++控制语句的使用
- c++输出语句
- c语句以句号结束对吗
- #define和printf是不是c语句?