子查询linq

时间:2010-06-14 22:18:52

标签: linq-to-entities subquery

嘿所有我想在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)
                                 }

1 个答案:

答案 0 :(得分:2)

每个子查询都返回Enumerable<Type>

尝试使用(from c in collection).First()或使用(from c in collection).FirstOrDefault()