開發工具與關鍵技術:visual studio 與c#
查詢兩個差不多相同的表,乙個是入庫表,乙個是退貨表,字段大致相同,但是有所差異,入庫表的數量和所有金額都是正數,退貨表的數量和金額都是負數,所以不能join鍊錶查詢,需要分開查詢出兩個tolist;但是return只能有乙個,不能return兩次,並且查詢出來的資料是放到乙個結算表,也不能有兩個action。所以我查詢兩次,一次join入庫表,一次join退貨表,查詢出來的資料到兩個list裡
listliststoragesettlement = (from tbsupplier in mymodels.sys_supplier
join tbpurchasestorage in mymodels.pw_purchasestorage on tbsupplier.supplierid equals tbpurchasestorage.supplierid
join tbinvoicestype in mymodels.sys_invoicestype on tbpurchasestorage.invoicestypeid equals
tbinvoicestype.invoicestypeid
where tbsupplier.supplierid == supplierid&&
tbpurchasestorage.settlestateid!=2&&tbpurchasestorage.settlestateid!=4
select new suppliervo
).tolist();
listlistreturnsettlement = (from tbsupplier in mymodels.sys_supplier
join tbpurchasereturn in mymodels.pw_purchasereturn on tbsupplier.supplierid equals tbpurchasereturn.supplierid
join tbinvoicestype in mymodels.sys_invoicestype on tbpurchasereturn.invoicestypeid equals tbinvoicestype.invoicestypeid
where tbpurchasereturn.supplierid == supplierid &&tbpurchasereturn.settlestateid != 2 &&tbpurchasereturn.settlestateid!= 4
select new suppliervo
).tolist();
查詢的兩個list集合list《實體類》必須是同乙個不然無法合併,查詢出兩個list資料集合後,使用
ienumerableintsresult =liststoragesettlement.union(listreturnsettlement)
進行重新例項乙個集合,ienumerable 公開列舉,集合可以進行簡單的迭代傳送,union是拼接兩個list資料集合的並集,最後只要返回intsresult就可以把兩個tolist的資料都return python將兩個list合併成乙個dict的方法
python將兩個list合併成乙個dict的方法 不使用內建函式,直接用 def run list2 1 2,3 4,5 list3 a b c d e dict i 0 length len list2 while i dict list2 i list3 i 這種方法也可以 dit dict ...
將排序序列的集合合併成乙個排序序列
您有乙個排序序列的集合,並且想要遍歷所有合併在一起的排序序列。先看如下示例,了解實際需求 import heapq a 1,4,7,10 b 2,5,6,11 for c in heapq.merge a,b print c 124 56710 11值得注意的是,heapq.merge要求所有的輸入...
兩個DATASET合併成乙個新的DATASET
摘自 dim i,j as integer dim dt1,dt2,dt3 as datatable dt1 mydataset.tables 0 dt2 mydataset.tables 1 mydataset.tables.add dt3 dt3 dt1.copy 首先將dt1的表機構和資料整體...