JoR
JoR

Reputation: 305

LINQ query to ado.data entity model selecting more than one column in c#

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

When I try to run a linq query against a ADO.net entity data model data source and return more than one column (c.Name,c.ID) it gives me error in C#

But in VB I am able to do it.

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

Any idea why?

Upvotes: 1

Views: 913

Answers (1)

James Curran
James Curran

Reputation: 103545

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

Upvotes: 3

Related Questions