/// <summary> /// Retrieves galleries by user with how many photos are in the gallery /// </summary> /// <param name="userId">Id of user</param> /// <returns></returns> public List <Gallery> RetrieveAllGalleriesByUserIdWithPhotoCount(int userId) { const string sql = @"Select G.GalleryID, [Name], [Description], G.AlbumId, G.UserId, PhotoCount From Gallery G Inner Join ( Select IG.GalleryID, IG.UserID, Count(PhotoID) as PhotoCount From Photo Inner Join Gallery IG On Photo.GalleryID = IG.GalleryID Where UserID = @UserID Group BY IG.GalleryID, IG.UserID ) as T1 ON G.GalleryID = T1.GalleryID Where G.UserId = @UserID And PhotoCount > 0" ; List <Gallery> galleries = galleryDb.RetrieveAllGalleriesByUserIdWithPhotoCount(userId, sql); return(galleries); }
/// <summary> /// Retrieves galleries by user with how many photos are in the gallery /// </summary> /// <param name="userId">Id of user</param> /// <returns></returns> public List <Gallery> RetrieveAllGalleriesByUserIdWithPhotoCount(int userId) { List <Gallery> galleries = galleryDb.RetrieveAllGalleriesByUserIdWithPhotoCount(userId, "Gallery_SelectAllGalleriesByUserIdWithPhotoCount"); return(galleries); }