1
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

知道为什么吗?

4

1 回答 1

3
 var lstnames = from c in oContext.tbl_ShippingProfile  
                select new 
                {
                   c.Name,
                   c.ID
                 };
于 2010-08-27T19:33:10.367 回答