LinqToEntities Question

Pho3nix

The Legend
Joined
Jul 31, 2009
Messages
32,825
Reaction score
3,033
Location
On the toilet
Hi guys,

I'm confused :?

I'm trying to run this code :
Code:
SELECT AVG(Rating) FROM [VideoRating]
Where VideoId = '1'
I should get a result of 3 ; but when converted to LinqToEntities from an app :
Code:
from videoratings in
(from videoratings in db.VideoRatings
where
  (Double)videoratings.VideoId == 
	(from videoratings0 in db.VideoRatings
	select new {
	  videoratings.Rating
	}).Average(p => videoratings.Rating)
select new {
  videoratings.Rating,
  Dummy = "x"
})
group videoratings by new { videoratings.Dummy } into g
select new {
  Column1 = (System.Double?)g.Average(p => p.Rating)
}

I get 2 :\ any reason for this. Will post up my own code in a bit, just been messing around so I have to rewrite it.

Thoughts?
 
Top
Sign up to the MyBroadband newsletter
X