How to use Linq To Sql to get Users who has less than 2 photos?

Posted by Mike108 on Stack Overflow See other posts from Stack Overflow or by Mike108
Published on 2010-04-05T12:11:02Z Indexed on 2010/04/05 13:23 UTC
Read the original article Hit count: 251

Filed under:

The scenario is I want to get the users who has less than 2 photos.

There are two table:

[Users] (UserId, UserName) 

[UserPhotos] (PhotoId, PhotoName, UserId) 

UserId is a Foreign Key but I do not want to use association like user.Photos.

A user may have none photo in the [UserPhotos] table.

How to use Linq To Sql to get List<User> who has less than 2 photos?

© Stack Overflow or respective owner

Related posts about linq-to-sql