List<T>.SelectMany(), Linq and lambda

c#, extension-methods, lambda, linq, nhibernate

Solution

It seems to me, that you want to filter the list `days`. If that's what you want, you should use

days.Where(i => i.MedicalRequest.MedicalUser == employee);

Problem

I have a class. ``` public class MedicalRequest { private int id private IList<MedicalDays> Days private string MedicalUser ... } ``` and another ``` public class MedicalDays { private int id; private DateTime? day private MedicalRequest request ... } ``` I'm using nhibernate to return a list of all the MedicalDays within a time span. I'd like to do something like this to the resulting list ``` //nhibernate query IList<MedicalDays> days = daysDao.FindAll(searchCritCollection); //select a list of days from resulting list IEnumerable<MedicalDays> queriedList = days.SelectMany(i => i.MedicalRequest.MedicalUser == employee); ``` Linq tells me that the type cannot be inferred by the usage. I'd like to know what I'm doing wrong, and if there is a preferred way of doing something like this. Thanks for your time.

Original source