Solved

Entity Framework 3 linq query

Posted on 2010-11-14
2
603 Views
Last Modified: 2013-11-11
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
Comment
Question by:xtremereality
2 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 34136392
How much do you know about LINQ?  What have you tried?  Are you getting errors?
0
 
LVL 16

Accepted Solution

by:
Stephan earned 500 total points
ID: 34215707
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question