开发者

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

开发者 https://www.devze.com 2022-12-31 12:18 出处:网络
I have a class. public class MedicalRequest { private int id private IList<MedicalDays> Days private string MedicalUser

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(searc开发者_如何学GohCritCollection);

//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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消