Entity Framework 3 linq query

Posted on 2010-11-14
Medium Priority
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

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

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

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
Question by:xtremereality
LVL 96

Expert Comment

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

Accepted Solution

Stephan earned 2000 total points
ID: 34215707

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
Watch the video of Kernel Migrator for SharePoint, which demonstrate the process easily of migration from SharePoint to SharePoint, OneDrive for Business & Google Drive servers, Public Folder to SharePoint, File Server to SharePoint. The tool has va…
If you are looking for an automated tool which can generate reports for Outlook emails and other items from PST file, then you can go for Kernel PST Reporter tool. The reports which are created by this tool are helpful to analyze and understand PST …

621 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