Solved

Entity Framework 3 linq query

Posted on 2010-11-14
2
600 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now