?
Solved

Entity Framework 3 linq query

Posted on 2010-11-14
2
Medium Priority
?
606 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 2000 total points
ID: 34215707
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

752 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