国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

vb.net Linq實戰

2019-11-08 03:12:08
字體:
來源:轉載
供稿:網友

VB.net 提供了通過Linq對數據集進行合計非常方法,可以減少了與數據庫的交互,提高系統性能,以下是sum示示例:

1、對字典對象的sum

dis.Sum(Function(a) a.Value) 'dis是Dictionary

當然也可以用 

Mytb.Compute("Sum(USM_TOTAL_CASH_MONEY)", "")2、對datatable的單字段sum

(From row In tmptable Select row.Field(Of Decimal)("customer_ds")).Sum() '
tmptable是DataTable對象,customer_ds是合計字段
3、對DataTable的多字段sum

 Dim sumtable2 = From r In MyTb               Group r By Key = New With {Key .Key = "合計"} Into g = Group              Select New With {.key = Key,                               .totalMoney = g.Sum(Function(x) IIf(IsDBNull(x("A1")), 0, x("A1"))),                               .saleMoney = g.Sum(Function(x) IIf(IsDBNull(x("A2")), 0, x("A2"))),                               .CaSh = g.Sum(Function(x) IIf(IsDBNull(x("A3")), 0, x("A3"))),                               .CardPay = g.Sum(Function(x) IIf(IsDBNull(x("A4")), 0, x("A4"))),                               .OtherPay = g.Sum(Function(x) IIf(IsDBNull(x("A5")), 0, x("A5"))),                               .CkPay = g.Sum(Function(x) IIf(IsDBNull(x("A6")), 0, x("A6"))),                               .DyqPay = g.Sum(Function(x) IIf(IsDBNull(x("A7")), 0, x("A7"))),                               .Minus = g.Sum(Function(x) IIf(IsDBNull(x("A8")), 0, x("A8"))),                               .orders = g.Sum(Function(x) IIf(IsDBNull(x("A9")), 0, x("A9"))),                               .newCards = g.Sum(Function(x) IIf(IsDBNull(x("A10").ToString().Split("/")(0)), 0, x("A11").ToString().Split("/")(0))) & "/" &                                           g.Sum(Function(x) IIf(IsDBNull(x("A11").ToString().Split("/")(1)), 0, x("A11).ToString().Split("/")(1))),        .cardInNums = g.Sum(Function(x) IIf(IsDBNull(x("充卡張數/金額").ToString().Split("/")(0)), 0, x("充卡張數/金額").ToString().Split("/")(0))) & "/" &                     g.Sum(Function(x) IIf(IsDBNull(x("充卡張數/金額").ToString().Split("/")(1)), 0, x("充卡張數/金額").ToString().Split("/")(1)))                              }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 依兰县| 上饶市| 塘沽区| 镇巴县| 右玉县| 台中市| 乌鲁木齐县| 北票市| 新竹市| 绍兴县| 兴义市| 嵩明县| 霍州市| 尼勒克县| 天津市| 拉孜县| 赣州市| 华坪县| 北票市| 仙桃市| 临汾市| 阳山县| 嘉定区| 阳西县| 巍山| 芜湖市| 亳州市| 开平市| 天全县| 遵义县| 诸城市| 新郑市| 宁乡县| 四子王旗| 富蕴县| 宿迁市| 株洲县| 琼海市| 封开县| 万盛区| 自贡市|