在项目中配置好DBEntities
使用两个表:主表Table, 子表Table_Item
主要是用到了委托和泛型,ForEach用的是不带返回值的委托
Sub GetDb() Dim st As New Stopwatch st.Start() Using db As New ApiDBEntities Dim d = db.Table.Join(db.Table_Item, Function(u) u.id, Function(g) g.MainId, Function(u, g) New With { .姓名 = u.name, .编号 = u.id} ) 'Dim e = d.Where(Function(t) t.n <> 1) Dim f = d.ToList f.ForEach(Sub(c) Console.WriteLine("打印数据{0}", c.姓名)) Console.WriteLine(d.ToString()) End Using st.Stop() Console.WriteLine("消耗时间={0}", st.ElapsedMilliseconds) End Sub