子查询 linq

发布于 2024-09-05 20:07:30 字数 1524 浏览 6 评论 0原文

嘿,我正在尝试在 linq 中执行子查询,但子查询是一个值,它似乎不起作用,任何人都可以帮忙吗?我正在使用实体框架,我不断收到和 int 到字符串错误,不知道为什么。

from lrp in remit.log_record_product
                                 join lr in remit.log_record on lrp.log_record_id equals lr.log_record_id
                                 where (lrp.que_submit_date >= RadDatePickerStartDate.SelectedDate) && (lrp.que_submit_date <= RadDatePickerEndDate.SelectedDate)
                                 select new { lrp.que_submit_date, 
                                     lr.officer_name, 
                                     lr.c_fname, 
                                     lr.c_lname, 
                                     lrp.price_sold, 
                                     lrp.product_cost,
                                     gap_account_number = (from gap in remit.gap_contracts where gap.log_record_product_id == lrp.log_record_product_id select gap.account_number),
                                     iui_account_number = (from iui in remit.iui_contracts where iui.log_record_product_id == lrp.log_record_product_id select iui.account_number),
                                     dp_account_number = (from dp in remit.dp_contracts where dp.log_record_product_id == lrp.log_record_product_id select dp.account_number),
                                     mpd_account_number = (from mpd in remit.mbp_contracts where mpd.log_record_product_id == lrp.log_record_product_id select mpd.product_account_number)
                                 }

Hey all I am trying to do a subquery in linq but the subquery is a value and it seems to not be working, can anyone help out? I am using the entit frame work I keep getting and int to string error not sure why.

from lrp in remit.log_record_product
                                 join lr in remit.log_record on lrp.log_record_id equals lr.log_record_id
                                 where (lrp.que_submit_date >= RadDatePickerStartDate.SelectedDate) && (lrp.que_submit_date <= RadDatePickerEndDate.SelectedDate)
                                 select new { lrp.que_submit_date, 
                                     lr.officer_name, 
                                     lr.c_fname, 
                                     lr.c_lname, 
                                     lrp.price_sold, 
                                     lrp.product_cost,
                                     gap_account_number = (from gap in remit.gap_contracts where gap.log_record_product_id == lrp.log_record_product_id select gap.account_number),
                                     iui_account_number = (from iui in remit.iui_contracts where iui.log_record_product_id == lrp.log_record_product_id select iui.account_number),
                                     dp_account_number = (from dp in remit.dp_contracts where dp.log_record_product_id == lrp.log_record_product_id select dp.account_number),
                                     mpd_account_number = (from mpd in remit.mbp_contracts where mpd.log_record_product_id == lrp.log_record_product_id select mpd.product_account_number)
                                 }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

橘香 2024-09-12 20:07:30

每个子查询都返回一个 Enumerable

尝试使用 (来自集合中的 c).First() 或使用 (来自集合中的 c)。 FirstOrDefault()

Each sub-query is returning an Enumerable<Type>

Try to use (from c in collection).First() or use (from c in collection).FirstOrDefault()

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