S
shapper
Hello,
I have two tables: Polls and Options:
Poll > PollID, Question
Options > OptionID, PollID, Answer
I want to select a Poll given its ID and all Options associated to
it.
Options should be converted to a CSV list ...
My Linq code is working but I feel I am having some redundancy in
it ... Could someone, please, check it out?
PollPaper paper = (from p in database.Polls
where p.PollID == id
select new PollPaper {
Poll = p,
Options = string.Join(", ", (from o in
database.Options
join ps in
database.Polls on o.PollID equals ps.PollID
orderby
o.Answer
select
o.Answer).ToArray())
}).SingleOrDefault();
Thank You,
Miguel
I have two tables: Polls and Options:
Poll > PollID, Question
Options > OptionID, PollID, Answer
I want to select a Poll given its ID and all Options associated to
it.
Options should be converted to a CSV list ...
My Linq code is working but I feel I am having some redundancy in
it ... Could someone, please, check it out?
PollPaper paper = (from p in database.Polls
where p.PollID == id
select new PollPaper {
Poll = p,
Options = string.Join(", ", (from o in
database.Options
join ps in
database.Polls on o.PollID equals ps.PollID
orderby
o.Answer
select
o.Answer).ToArray())
}).SingleOrDefault();
Thank You,
Miguel