Friday 15 June 2012

c# - Inner left join with linq returns too many results -


I have been living for years since I'm finally working with joining, so I'm a little confused now. <3> There are 3 tables

Albums, albums and images

Now before my repository I have been included in album and album images in Inner Warner, this is the only thing I want to do is enter the first entry I cover diska i id decks (album images can have 0 images!) Its b The I get involved in user on user ID ID of the user in the user table. My problem is that I have not got only 1 album, but there is a result in the albums for each image, where I only have to do 1. What am I doing wrong here?

  Public IQueryable & lt; Album & gt; The albums from the cover in the pictures of the album are equal to I.AlbumId in the image. Cover with Default IfEmpty () Order Descending cover, cover. Select ID climb above the ID () {ID = AID, User ID = AUSIRID, name = A.Name, created = A. Ready, Last Edit = AalAdit, Details = A.Description, View = A. View, Location = A place, Photoshoot = A. Photoshoot, cover = cover,}); } Album of album (= one of the album repository) in user.Repository.Get () in a.UserId is equal to U. A.Id descending from A.Id descending new album display model () {album = A, User = u}). to list();   

Test:

  Return (Join the album in context in _imageRepository.Get (I). I. Albums equal to albums on album. In an album in the album from the album, select the default IfEmpty () new album () (id = AIID, userID = a.UserId, name = a.Name, created = A created, last edit = a.LastEdit, Description = a.Description, View = A.Views, Location = A. Location, Photoshoot = A. Photoshoot, Cover = i,});    

close DefaultIfEmpty to AlbumImages . This album is going to return image whether it is a match or not (include left).

No comments:

Post a Comment