views:

56

answers:

1

I have a the following setup

m_handsets = From p In RL.App.TComEntities.tblTelephoneNumbers _
                                               Where p.companyId = m_CompanyID _
                                               Select p

m_handsets = DirectCast(m_handsets, ObjectQuery(Of RL.TelephoneNumbers)).Include("tblCalls")

where m_handsets is defined as

Private m_handsets As IQueryable(Of RL.tblTelephoneNumbers)

which works as expected however what I want to do know is query the Navigation property (tblCalls) so I can do something like the following

From p In m_handsets.tblCalls 
Where m_handsets.tblCalls.price > 100

but I have no idea of the proper syntax, can anyone help?

EDIT:

I think the complexity comes here because in this instance I could have 5 tblTelephoneNumbers in m_handsets and then x amount of calls for that particular telephone number. I am interested in the tblCalls for each but I would like to filter them all for each tblTelehoneNumber.

Entity Diagram which (hopefully) should illustrate further diagram

So I currently know all the handsets that are associated with the company I am interested in. I can also see the calls loaded as a navigation property in debug mode, but I want to say is take this filter (in this example price>100 and apply it to all handsets->calls

+1  A: 
Morteza Manavi
Excuse my ignorance Is this right? Does this not defeat the purpose of include as I am having to go and get all data from data calls filter it and then tie it back to a tbltelephoneNumbers, where the navigation property has already the steps other than filter it?
Dean
Like I mentioned, the point really is that *there is absolutely no way to filter included data with include() mehtod.* My both suggested ways are kind of workarounds for this limitation of include method and I just added yet another way to my answer, check it out.
Morteza Manavi
Thanks for the info. I like option 3 as that kind of makes sense to me and was also an approach I had discovered in the meantime almost by accident :-)
Dean
No problem. Honestly, I answered this question a few times before in SO and most of the guys were happy with either option 1 or 2, but in this case I decided to come up with a better solution and yes I also like the last solution more than the others.
Morteza Manavi