我有一段这样的代码。
MortgageProduct abc = ( from product in dbn.mortgageproducts
join scraper in dbn.mortgagescrapers
on product.Id equals scraper.Id
select cast(product, scraper)).FirstOrDefault();
并且演员功能在这里。请注意,显式转换运算符已重载 在MortgageProduct和抵押品之间
private static MortgageProduct abc(mortgageproduct mor, mortgagescraper ms) {
var mort = ((MortgageProduct)(mor));
mort.LastMonitorTime = ms.LastMonitorTime ?? DateTime.MinValue;
mort.NextMonitorTime = ms.NextMonitorTime ?? DateTime.MinValue;
return mort;
}
但我想将强制转换函数转换为lambada表达式 我该如何实现这一功能。
var abc = (from product in dbn.mortgageproducts
join scraper in dbn.mortgagescrapers
on product.Id equals scraper.Id
select(() =>
{
MortgageProduct newmort = (MortgageProduct )product;
newmort.date = scraper.date;
return newmort;
})).FirstOrDefault();
当我尝试第二种方法时,它显示错误“连接子句中某个表达式的类型不正确。在”加入“的调用中类型推断失败”