承接基于.Net的系统研发,精通物流系统,特别是仓储物流管理,有意者请联系。

Linq备忘

有些用法老是记不住,现在记录在网上,下次就容易查到了,不必到处搜索了。

1、Groupby

 

var tempPlanGoodsItems =
                (from p in m_StockInPlan.GoodsItems
                group p by new { p.GoodsName, p.MaterialNo, p.CompanySerialNo, p.SpecAndModel, p.BatchNo, p.SkuNo } into g
                select new RestGoodsItem
                {
                    GoodsName = g.Key.GoodsName,
                    MaterialNo = g.Key.MaterialNo,
                    CompanySerialNo = g.Key.CompanySerialNo,
                    SpecAndModel = g.Key.SpecAndModel,
                    BatchNo = g.Key.BatchNo,
                    SkuNo = g.Key.SkuNo,
                    PlanQuantity = g.Sum<PlanGoodsItem>(p => p.Quantity),
                    Quantity = 0,

                }).ToList<RestGoodsItem>();

 

2、主子表查询(子表条件)

 IList<StockOutPlan> stockOutPlans = m_StockOutPlanBizService.CreateQueryNoNoLazies("select distinct p from StockOutPlan as p inner join p.GoodsItems as g where g.StockInPlanNo='" + m_StockInPlan.PlanNo + "'", new List<string> { StockOutPlan.NON_LAZY_GOODSITEMS});

posted @ 2011-02-21 16:44  阿修罗一平  阅读(243)  评论(0编辑  收藏  举报