Answer 2
Hi MarkSA,
If you want to select particular columns, you can use projections in your query and shape your results by picking particular properties rather than entities. If the column you are returning is always different and you want to choose the column dynamically,
you can use projecting with query builder methods, something like :
Dim context AsNew NorthwindEntities
Dim colSel AsString = "CompanyName"'Column name you want to select. You can change the name to othersDim customQuery = context.Customers.Where("it.CustomerID = 'VINET'").Select("it." & colSel)
ForEach mm In customQuery
Console.WriteLine(mm.Item("CompanyName").ToString)
Next
And I think you can also achieve what you want using Dynamic LINQ.
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
By the way, I am moving this thread to "ADO.NET Entity Framework and LINQ to Entities" forum for better response.
Best regards,
Alex Liang
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact
msdnmg@microsoft.com