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

时间:2009-06-04 13:46:19

标签: vb.net linq

如果您有自定义类型,并且希望将List(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 个答案:

答案 0 :(得分:3)

Dim result = (From c in db.Customers _ 
              Where c.orders.Count > 1 _
              Select new Myclass With { _
              {
                 .Id = c.customerID, _
                 .Name = c.contactname _
              }).ToList()