LINQ查询ado.data实体模型在c#中选择多个列

时间:2010-08-27 19:26:39

标签: linq ado.net-entity-data-model

ECommerceAdoEntities oContext = new ECommerceAdoEntities();           
var lstnames = from c in oContext.tbl_ShippingProfile  select c.Name;

当我尝试针对ADO.net实体数据模型数据源运行linq查询并返回多个列(c.Name,c.ID)时,它在C#中给出了错误

但是在VB中我能够做到。

Dim adoDataEntity As New ECommerceAdoEntities()
Dim lstAdoSource = From c In adoDataEntity.tbl_ShippingProfile Select c.Name, c.ID

知道为什么吗?

1 个答案:

答案 0 :(得分:3)

 var lstnames = from c in oContext.tbl_ShippingProfile  
                select new 
                {
                   c.Name,
                   c.ID
                 };