运行此Linq查询时出现“NotSupportedException”。 “不支持指定的方法。”什么方法?即使将“Count()”注释掉,错误也是一样的。空内部异常。
堆栈追踪:
at Hydra.WPF.ViewModels.AddressListViewModel._primaryMemberListWorker_DoWork(Object 发件人,DoWorkEventArgs e)in M:\项目\水润\ WPF \的ViewModels \ AddressList中\ AddressListViewModel.cs:行 1377年 System.ComponentModel.BackgroundWorker.WorkerThreadStart(对象 参数)
SQL查询:
Select * From _Members
Inner Join AddressDetailsCCN a on a.MemberId=_Members.MemberID
Inner Join
(
Select Address+Address2 as CombinedAddress
From AddressDetailsCCN Where ListId=84
group by Address+Address2
Having COUNT(*)>1
) B on B.CombinedAddress=A.Address+A.Address2
Where CombinedAddress is not null AND CombinedAddress!='' AND a.ListId=84
Order by ClientID, CombinedAddress
Linq:
var grouped =
(from mem in session.Query<Member>()
join detail in session.Query<Detail>() on mem.Id equals detail.Member.Id
join d2 in (from d3 in session.Query<Detail>()
where d3.AddressList.Id == criteria.AddressList.Id
group d3 by d3.Address + d3.Address2 into x
where x.Count() > 1
select x) on detail.Address+detail.Address2 equals d2.Key
where detail.AddressList.Id==criteria.AddressList.Id
select mem);
答案 0 :(得分:0)
您如何生成标准变量?如果这本身就是一个延迟查询或其他东西,它听起来像是可能的罪魁祸首。如果在查询之前执行var criteriaId = criteria.AddressList.Id;
会发生什么情况,并为查询而不是条件提供criteriaId.AddressList.Id?