List.SelectMany()、Linq 和 lambda

发布于 2024-09-02 05:50:26 字数 750 浏览 8 评论 0原文

我有课。

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最好是你 2024-09-09 05:50:26

在我看来,您想要过滤列表days。如果这就是你想要的,你应该使用

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文