Tech Off Post

Single Post Permalink

View Thread: LINQ to Entities and using a collection in the query...
  • User profile image
    ulas

    dpratt71 said:

    The most straightforward way I can think to do this involves stepping outside the "from...in" syntax a bit:

    var myClubs =
        from aClub in myDB.Club
        where aClub.Users.Any(aUser => aUser.City == city)
        select aClub;

    This assumes that the navigation property from Club to User is named "Users" (if you haven't changed anything, it's probably "User").

    Ah, thanks for the reply Smiley I will give this a try in a bit and let you know what happens Smiley

    Quick question though - what is the main reason why my initial version was not working? Did I miss something obvious or is this a matter of lack of support in Linq for a particular type of query? (during runtime since VS does not complain at compiletime).

    ulas