use the Cast method of IEnumerable:
Cast query result to list of anonymous class
سؤال
Can anyone give me a method to convert the result of a select query to list of class? I want that so I can later use LINK to objects.
I'm using sql server 2008 and vb.net. For example, I have a table in DB having two columns:
{ProductID, ProductName}
I execute a select query "Select * From Products"
and fill it in a dataset DS.
I want a way so I can convert the result of the above query's result (or any query that returns any set of result) to a list of an existing class in my vb.net project, in my example Product class that has two properties (ProductID and ProductName).
I hope my question is clear enough.
المحلول
لا تنتمي إلى StackOverflow