代码之家  ›  专栏  ›  技术社区  ›  Aaron M

在LINQ查询中使用自定义类型

  •  0
  • Aaron M  · 技术社区  · 17 年前

    如果您有自定义类型,并且希望为该自定义类型分配一个List(of T),如何在vb中执行此操作?我找到了一个C#示例,如下所示

    List<myclass> result = (from c in db.Customers where c.orders.count > 1 Select new Myclass
    {
    Id = c.customerID,
    Name = c.contactname
    }).Tolist();
    

    从这个网站 http://blogs.msdn.com/swiss_dpe_team/archive/2008/01/25/using-your-own-defined-type-in-a-linq-query-expression.aspx

    但我一直在努力让它在Vb.net中工作

    1 回复  |  直到 17 年前
        1
  •  3
  •   Mehrdad Afshari    17 年前
    Dim result = (From c in db.Customers _ 
                  Where c.orders.Count > 1 _
                  Select new Myclass With { _
                  {
                     .Id = c.customerID, _
                     .Name = c.contactname _
                  }).ToList()