king 发布的文章

  1. 常用方法

    #Header
    *斜體*
    **粗體**
    ***粗斜體***
    >引用
    超鏈接[notes](url)
    圖片[notes](url)
    代碼塊  反引號
    1. 2. 3. 列表
    - 無序列表
    段落用空行
    換行   
    分割線  ***  ---  _
    轉義   \
    html用法
    表格
  2. 實例
  • img:
    notes
  • 代碼塊:

    #python
    def hello(): 
        print("hello world!")
  • 表格

    nameagetel
    king2233
  • html

    1.<span style="color:red; font-size:32px">html span</span>
    2.<pre>hello world!          wa</pre>
    3.<code>print("hello world!")</code>

    html span

    hello world!          wa

    print("hello world!")




  1. 注意事項

Sub Main()

' 1. 初始化資料
Dim dep As New datatable
Dim emp As New datatable
Dim tmp0 As New datatable
Dim tmp As New datatable
Dim tmp2 As New datatable
Dim tmp3 As New datatable
dep.columns.add("id",Gettype(Integer))
dep.columns.add("name",Gettype(String))
dep.rows.add(1,"pe")
dep.rows.add(2,"me")
dep.rows.add(3,"ie")
emp.columns.add("id",Gettype(Integer))
emp.columns.add("name",Gettype(String))
emp.columns.add("depId",Gettype(Integer))
emp.rows.add(1,"king",1)
emp.rows.add(2,"lily",1)
emp.rows.add(3,"bob",4)

tmp.columns.add("id",Gettype(Integer))
tmp.columns.add("name",Gettype(String))
tmp.columns.add("depId",Gettype(Integer))
tmp.columns.add("depName",Gettype(String))

tmp0=tmp.clone()
Dim res = emp.asenumerable().Join(
    dep.asenumerable,
    Function(l) l.Field(Of Integer)("depId"),
    Function(r) r.Field(Of Integer)("id"),
    Function(g,e) tmp0.loaddatarow(
        g.ItemArray.concat({If(e Is Nothing,"no",e("name"))}).toarray(),False
        )
    )        
res.count()
Call "tmp0".Dump()
tmp0.Dump()    

res = emp.asenumerable().GroupJoin(
    dep.asenumerable,
    Function(l) l.Field(Of Integer)("depId"),
    Function(r) r.Field(Of Integer)("id"),
    Function(l,gg) New With { l, gg}
    ).SelectMany(
    Function(g) g.gg.defaultifempty(),
    Function(g,e) tmp.loaddatarow(
        g.l.ItemArray.concat({If(e Is Nothing,"no",e("name"))}).toarray(),False
        )
    )
    
res.count()
Call "tmp:".Dump()
tmp.Dump()        

tmp2=tmp.clone()    
Dim res2 = From l In emp.AsEnumerable()
  Join r In dep.AsEnumerable()
  On l("depId") Equals r("id")
  Select tmp2.LoadDataRow(l.ItemArray.Concat({ r("name") }).ToArray(), False)
res2.count()
Call "tmp2:".Dump()
tmp2.Dump()

tmp3=tmp.clone()
Dim res3 = From l In emp.AsEnumerable()
  Group Join r In dep.AsEnumerable()
  On l("depId") Equals r("id")
  Into gg=Group
  From s In gg.defaultifempty()
  Select tmp3.LoadDataRow(l.ItemArray.Concat({ If(s Is Nothing,"...",s("name")) }).ToArray(), False)

res3.count()
Call "tmp3:".Dump()
tmp3.Dump()

End Sub