locked
linq group join RRS feed

  • Question

  •  

    Hi All

     

    i am busy struggling with a linq function. i am trying to achieve the equivalant output that the following SQL gives:

     

     

    select b.documenttypename, b.url + '/' + a.documentpath as url, a.note, a.createddate, a.userdocumentid, a.documentpath from App_UsersDocuments a join DocumentType b on a.DocumentTypeID = b.DocumentTypeID where b.isSystemType = 1 and a.UserID = @UserID

     

    my linq function is as follows:

     

    Public Function GetUserSystemDocumentsDetail(ByVal userid As Guid) As IList

     

                Dim dd = (From d In db.App_UsersDocuments Where d.UserID = userid Join a In db.DocumentTypes On a.DocumentTypeID Equals d.DocumentTypeID Select a.DocumentTypeName, url = a.URL & "/" & d.DocumentPath, d.Note, d.CreatedDate, d.UserDocumentID, d.DocumentPath).ToList

     

                Return dd

            End Function

     

    The problem is i do not know how to write my linq statement to allow a 'double where clause'. ie select from DocumentType where isSystemType is true and from App_UsersDocuments where userid matches the parameter value.

     

    At the moment the function returns all documents whether they are a system type or not. apparently i should use a group join here but i dont know the correct syntax.

     

    PLEASE HELP. i am running out of time....

     

    Chris

    Monday, July 7, 2008 12:08 PM