How to use WHERE clause on related table in LinqDataSource

I've used the LinqDataSource successfully with a WHERE clause that applies to the table being selected.

What I need to do now, is select data from the table after using a WHERE clause on a related table instead of the "current" table.

Can this be done with LinqDataSource (I'm using LinqDataSource both for fast prototyping, plus built-in paging capabilities w/ GridView)?

I have 2 table objects in my User.dbml:
Provider: List of course providers)
ProviderXUser: Cross-reference table listing which of my website's users (UserDetails table) are also members of a Provider

I tried the following, but it throws the error (I've double-checked that FkUserDetailsId does exist in ProviderXUsers):
"No property or field 'FkUserDetailsId' exists in type 'EntitySet`1'"

        <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="UserDataContext"
        TableName="Providers" Where="ProviderXUsers.FkUserDetailsId == 1 " >
          <asp:Parameter DefaultValue="1" Name="Type" Type="Int32" />
Who is Participating?
cdakzAuthor Commented:
I looked over but it wasn't clear what the solution was to me.

What I was after was a way to use the datasource "wizard" so that I could, through its UI, generate the correct code.

From what I've gathered since posting this question, the way to accomplish this is programmatically, in the _Selecting event, as explained at:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.