Using LINQ can I get the data from the table into the format shown directly below? Can LINQ perform this type of formating or should I loop through the results to format?
Format I’m trying to get data into:
dau gmu population year
------ ---------- ---------- -------
1 2, 201 1680 2010
2 3, 4, 5, 14 14570 2010
DATA IN TABLE:
id dau gmu population year species
----------- ----------- ----------- ------------------- ---- -------
1 1 2 1680 2010 E
2 1 201 1680 2010 E
3 2 3 14570 2010 E
4 2 4 14570 2010 E
5 2 5 14570 2010 E
6 2 14 14570 2010 E
The actual formatting will be up to you, but assuming that you have a collection of these items called
list, you can do this:You may have to pull this into an in-memory list to do this, if you’re actually dealing with L2E.
EDIT: Just tried it with L2E and it seems to work fine as written. Instead of
listin your query, it will be something more likecontext.TableName.Here’s the full code. The output is very sloppy, but it’s late, and I don’t think the OP was worrying about the formatting so much: