zoukankan      html  css  js  c++  java
  • vb.net DBEntities框架联表查询 Join

    在项目中配置好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
    

      

  • 相关阅读:
    Redis
    Redis
    运维
    Redis
    Redis
    Redis
    Redis
    Redis
    Redis
    Spring
  • 原文地址:https://www.cnblogs.com/wujiangling/p/9968412.html
Copyright © 2011-2022 走看看