Hello,
I have three tables: Polls (PollId, Question), Options (OptionID,
Answer) and Votes (VoteID, OptionID)
I then created two Wrapper Classes:
PostPaper with the following properties:
public Poll Poll { get; set; }
public List<OptionPape rOptions { get; set; }
public string OptionsCSV { get; set; }
OptionPaper with the following properties:
public Option Option { get; set; }
public int Votes { get; set; }
I need, given an PollId, to get fill a PostPaper with all its options
and for each option count the votes:
pollViewData.Po llPaper = (from p in database.Polls
join o in database.Option s on p.PollID
equals o.PollID
join v in database.Votes on o.OptionID
equals v.OptionID
where p.PollID == id
group o by p into pog
select new PollPaper {
Poll =
pog.Key,
Options = new List<OptionPape r{
Option = ??????
Votes = ?????
}.ToList(),
OptionsCSV = string.Join(", ",
pog.Select(o =o.Answer).ToAr ray())
}).SingleOrDefa ult();
I am having problems in creating the Option and Count the votes of
each OptionPaper in List Options.
Could someone, please, help me out?
Thanks,
Miguel
I have three tables: Polls (PollId, Question), Options (OptionID,
Answer) and Votes (VoteID, OptionID)
I then created two Wrapper Classes:
PostPaper with the following properties:
public Poll Poll { get; set; }
public List<OptionPape rOptions { get; set; }
public string OptionsCSV { get; set; }
OptionPaper with the following properties:
public Option Option { get; set; }
public int Votes { get; set; }
I need, given an PollId, to get fill a PostPaper with all its options
and for each option count the votes:
pollViewData.Po llPaper = (from p in database.Polls
join o in database.Option s on p.PollID
equals o.PollID
join v in database.Votes on o.OptionID
equals v.OptionID
where p.PollID == id
group o by p into pog
select new PollPaper {
Poll =
pog.Key,
Options = new List<OptionPape r{
Option = ??????
Votes = ?????
}.ToList(),
OptionsCSV = string.Join(", ",
pog.Select(o =o.Answer).ToAr ray())
}).SingleOrDefa ult();
I am having problems in creating the Option and Count the votes of
each OptionPaper in List Options.
Could someone, please, help me out?
Thanks,
Miguel
Comment