I am using Entity Framework 3.5. My model has a Mediator table and a MediatorAvailabilities table. Most Mediators do not have an entry in MediatorAvailabilities (Availability = Null) but I still need to bring back the mediator whether or not there is a related MediatorAvailabilities.
My query below is only bring back a mediator if there is a related Availability. Again how do I get mediators even if Availability = null?:
Dim mediators = (From m In entity.Mediators.Include("MediatorAvailabilities") _
Where(m.MediatorAvailabilities.Any(Function(a) a.Availability = String.Empty Or a.Availability.Contains("Weekends") = True))
Where (m.isActive = True) _
Order By m.Sequence _
Select New RankingCriteria() With { _
.FirstName = m.FirstName, _
.LastName = m.LastName, _
.CompanyName = m.CompanyName, _
.PhoneHome = m.PhoneHome, _
.PhoneWork = m.PhoneWork, _
开发者_如何转开发 .PhoneMobile = m.PhoneMobile, _
.Email = m.Email _
}).ToList()
What's the correct way to do this?
I think you need to add a.Availability is Nothing
in your Any
method call like so:
Where(m.MediatorAvailabilities.Any(Function(a) a.Availability is Nothing Or a.Availability = String.Empty Or a.Availability.Contains("Weekends") = True))
精彩评论