子查询 linq
嘿,我正在尝试在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每个子查询都返回一个
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()