• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 609
  • Last Modified:

Entity Framework 3 linq query

Hi Experts,
Hi have to query the database in order to have a list of answers.
This is the situation:
I have 3 entities

PoolQuestion
Id (scalar property)
Text (scalar property)
IsEnabled (scalar property)
IsPublished (scalar property)
PollAnsers (navigation property)
PollResults (navigation property)

PollAnswer
Id (scalar property)
Text (scalar property)
Order (scalar property)
IsEnable (scalar property)
PollAnsers (navigation property)
PollResults (navigation property)

PollResult
Id (scalar property)
UserId (scalar property)
IsEnabled (scalar property)
PollAnswer (navigation property)
PollQuestion (navigation property)

When a user votes I add a new entry on PollResult.

Let's say the question is: Do you like icecream?
And the answers can be: Yes, No, Maybe

The PollResult as table on the db is:

Id,      PollQuestion_Id,      PollAnswer_Id,      UserId,     IsEnabled
-------------------------------------------------------------------------
1     |      2              |    6              |  1         | true
2     |      2              |    4              |  2         | true
3     |      2              |    4              |  3         | true

Open in new window


What I need is to get a result like

Question,                  Yes,         No,        Maybe
-----------------------------------------------------
Do you like Icecream?   |  10      |   3       |   0
Do you like devloping?  |  9       |   1       |   3

Open in new window


The relations are

PollQuestion 0.1 To many with PollResult,
PollQuestion 0.1 To many with PollAnswer,
PollAnswer 0.1 To many with PollResult

Basically I need for all the questions, aggregate and count all answers for a given question
I have to use Entity framework 3/c#

Any idea?

Thanks in advance
0
xtremereality
Asked:
xtremereality
1 Solution
 
Bob LearnedCommented:
How much do you know about LINQ?  What have you tried?  Are you getting errors?
0
 
StephanLead Software EngineerCommented:
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now