I have a dynamic sql query which contains more than one table joined. Normally I get this query to a datatable and use it. For now I want to get result of this query to a list object. Does anyone help me about this case?
+1
A:
You'll have to loop through the rows of the datatable, populate the column values to the properties of an object, add the object to the list and then return the list. Alternatively you could consider using a ORM tool like NHibernate.
Raj
2010-05-05 12:33:07
If I have many rows returned from the query, it will take many time to perform this.
mavera
2010-05-05 12:47:48
+1
A:
If this query does not change very much you could create a stored procedure from it and implement the stored procedure in the Linq2SQL designer. This would give you the ability to just write
var MyResult = context.spMyStoredProcedure(var1, var2);
If I'm not completely wrong... Writing from memory ;)
Christian W
2010-05-05 18:46:10