(lst).FindAll(t => t.parent_warehouse_id == warehouse.warehouse_id);
if (itemLst.Count > 0)
string[] strstr = new string[itemLst.Count];
strstr = itemLst.Select(c => c.category_id).ToArray();//选取list中的一列,赋值给数组
cateIDs = strstr;
2.linq的union与group by
var query2 = from t in
((from p in context.AMS_Plan_Item
join p1 in context.AMS_Plans on p.plan_id equals p1.plan_id into pAndP1
from LFPAndP1 in pAndP1.DefaultIfEmpty()
where p.plan_type == 1 && LFPAndP1.year == year && LFPAndP1.month == month
select new
plan_item_id = p.plan_item_id,
plan_id = p.plan_id,
asset_id = p.asset_id,
department_id = p.department_id,
plan_type = p.plan_type,
amount = p.amount,
audit_status = p.audit_status,
audit_description = p.audit_description,
reason = p.reason,
username = p.username,
backname = p.backname,
create_date = p.create_date,
back_date = p.back_date,
totalprice = p.totalprice,
SortCode = p.SortCode,
).Union(from p in context.AMS_Plan_Item
join p1 in context.AMS_Plans on p.plan_id equals p1.plan_id into pAndP1
from LFPAndP1 in pAndP1.DefaultIfEmpty()
where p.plan_type == 0 && LFPAndP1.year == year && LFPAndP1.month == month1
select new
plan_item_id = p.plan_item_id,
plan_id = p.plan_id,
asset_id = p.asset_id,
department_id = p.department_id,
plan_type = p.plan_type,
amount = p.amount,
audit_status = p.audit_status,
audit_description = p.audit_description,
reason = p.reason,
username = p.username,
backname = p.backname,
create_date = p.create_date,
back_date = p.back_date,
totalprice = p.totalprice,
SortCode = p.SortCode,
})).DefaultIfEmpty()
join a in context.AMS_assets on t.asset_id equals a.asset_id into tAndA
from LFTAndA in tAndA.DefaultIfEmpty()
join u in context.AMS_units on LFTAndA.unit_id equals u.unit_id into aAndU
from LFAAndU in aAndU.DefaultIfEmpty()
join m in context.AMS_manufacturers on LFTAndA.manufacturer_id equals m.manufacturer_id into aAndM
from LFAAndM in aAndM.DefaultIfEmpty()
join b in context.AMS_brands on LFTAndA.brand_id equals b.brand_id into aAndB
from LFAAndB in aAndB.DefaultIfEmpty()
join p in context.AMS_Plans on t.plan_id equals p.plan_id into tAndP
from LFTAndP in tAndP.DefaultIfEmpty()
join cate in context.AMS_asset_categories on LFTAndA.category_id equals cate.category_id into aAndCate
from LFAAndCate in aAndCate.DefaultIfEmpty()
join ware in context.AMS_warehouses on LFAAndCate.parent_warehouse_id equals ware.warehouse_id into cateAndWare
from LFCateAndWare in cateAndWare.DefaultIfEmpty()
group t by new {LFTAndA.spinyin,LFTAndA.lpinyin, categoryid=LFAAndCate.category_id,categoryname=LFAAndCate.name, AssertName = LFTAndA.name, AssetId = t.asset_id, LFTAndA.alias, LFTAndA.price, LFTAndA.spec, unitname = LFAAndU.name, manuname = LFAAndM.name, brandname = LFAAndB.name } into gs
select new AMS_Plan_ItemView
category_id=gs.Key.categoryid,
categoryname=gs.Key.categoryname,
AssetId = gs.Key.AssetId,
AssertName = gs.Key.AssertName,
alias = gs.Key.alias,
price = gs.Key.price,
spec = gs.Key.spec,
Amount = gs.Sum(c => c.amount),
totalprice = gs.Sum(c => c.totalprice),
lpinyin = gs.Key.lpinyin,
spinyin = gs.Key.spinyin,
unitname = gs.Key.unitname,
manuname = gs.Key.manuname,
brandname = gs.Key.brandname,
string[] cateIDs={} ; List itemLst = IListHelper.IListToList(lst).FindAll(t => t.parent_warehouse_id == warehouse.warehouse_id); if (itemLst.Count > 0)
nt maxcount = Model
.SelectMany(h => h.DetailList).OrderBy(h => h.DetailType)
.GroupBy(h => h.DetailType).Select(h => h.Count()).Max();
int Fitsetcount = Model.SelectMa...
id NAME result
----------- -------------------- ------
1 jim 胜
2 jim ...
public int id { set; get; }
public string name { set; get; }
public int typeid { set; get; }
#region 准备数据
List<UserInfo> U
/// </summary>
/// <param name="dataTable">需要进行行转列的表</param>
/// <param name="groupingColumn">需要进行行转列的字段</param>
/// <param name="nameColumn"&g.