当我运行以下查询(VB中的asp.net)时,我得到“无法将类型'System.String'强制转换为'System.Object'.LINQ to Entities仅支持转换实体数据模型基元类型。 “错误。我已尝试过多次查询,但得到了错误。
我认为它与连接和选择有关。有什么想法吗?
来自评论
query = (from p in context.Clients
join j in context.Loans on p.Number equals j.ClientNum
join lb in context.LIBORs on lb.LoanNum equals j.LoanNum
join w in context.WUserIDs on w.RegionNum equals j.RegionNum
join f in context.FASBs on f.LoanNum equals j.LoanNum
select j.RateType, j.LoanNum, lb, w, f).ToList()
答案 0 :(得分:1)
你需要改变两件事: 1.使用连接条件指定第一个变量,然后指定第二个变量。 2.选择一个对象。
var query = (from p in context.Clients
join j in context.Loans on p.Number equals j.ClientNum
join lb in context.LIBORs on j.LoanNum equals lb.LoanNum
join w in context.WUserIDs on j.RegionNum equals w.RegionNum
join f in context.FASBs on j.LoanNum equals f.LoanNum
select new { j.RateType, j.LoanNum, lb, w, f}).ToList();