按lambda

时间:2019-02-26 11:02:30

标签: c# linq lambda

我有Queryable个对象

IQueryable<Orders> orders = Repository.GetOrders();

我现在有了带有一些常见orderId的订单列表,我只需要获取可查询对象中最新的orderIds的唯一date

Queryable<Orders> ordersWithLatestDate = orders.Where(?) <=(此处需要Lambda查询)

1 个答案:

答案 0 :(得分:0)

您可以按When this checkbox is selected, the compiler "wakes up" upon any change to a TypeScript file. When this checkbox is cleared, the compiler ignores changes to TypeScript files. To re-activate the compiler, open the TypeScript Tool Window (View | Tool Windows | TypeScript), click icon_ts_compile_all on the toolbar, and choose the compilation scope from the list: If you have not opened the TypeScript tool window yet and it is not available from the View menu, choose Help | Find Action, then find and launch the TypeScript Compile All action from the list. 对订单进行分组,然后将每个组投影在日期列上:

Id

编辑:

这也可以与IQuerable一起使用:

var ordersWithLatestDate = orders.GroupBy(x => x.Id)
                            .Select( g => new 
                                { 
                                    Orderid = g.Key, 
                                    OrderDateTime = g.OrderByDescending(x => x.OrderDateTime)
                                                     .Select(y => y.OrderDateTime)
                                                     .First()
                                });