List.SelectMany()、Linq 和 lambda
我有课。
public class MedicalRequest
{
private int id
private IList<MedicalDays> Days
private string MedicalUser
...
}
另一个
public class MedicalDays
{
private int id;
private DateTime? day
private MedicalRequest request
...
}
我使用 nhibernate 返回一个时间范围内所有 MedicalDays 的列表。我想对结果列表执行类似的操作,
//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 告诉我无法通过用法推断类型。我想知道我做错了什么,以及是否有更好的方法来做这样的事情。
感谢您抽出时间。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在我看来,您想要过滤列表
days
。如果这就是你想要的,你应该使用It seems to me, that you want to filter the list
days
. If that's what you want, you should use