How do I return multiple columns with linq to sql in C#?
I tried to end my query with
select new { A.Product, A.Qty };
but this returns some anonymous type and I am not sure what the heck what to do with this, How to return it and how to extract information out of it. I want to put it in some sort of array.
thanks
SLaks :
Are you trying to return the data from a method?\n\nIf so, you should just end the query with select A, which will produce the same type that A is.\n\nIf not, you can use the anonymous type the same way you use a regular type.\n\nFor example:\n\nvar results = from ... select new { A.Product, A.Qty };\n\nforeach(var thing in results) {\n Console.WriteLine(\"{0}: {1}\", thing.Product, Thing.Qty);\n}\n\n\nEDIT: To make it into a list, call ToList, like this:\n\nvar resultsList = results.ToList();\n",
2009-12-11T01:03:14