5

运行此 Linq 查询时出现“NotSupportedException”。“不支持指定的方法。” 什么方法?即使注释掉了“Count()”,错误也是一样的。空内部异常。

堆栈跟踪:

在 Hydra.WPF.ViewModels.AddressListViewModel._primaryMemberListWorker_DoWork(Object sender, DoWorkEventArgs e) in M:\Projects\Hydra\WPF\ViewModels\AddressList\AddressListViewModel.cs: System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument) 的第 1377 行

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

林克:

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);
4

1 回答 1

0

你如何产生你的标准变量?如果这本身就是一个延迟查询或其他东西,那听起来可能是罪魁祸首。如果您var criteriaId = criteria.AddressList.Id;在查询之前执行 a,并为您的查询提供 criteriaId 而不是您的 criteria.AddressList.Id,会发生什么?

于 2012-07-21T17:34:55.680 回答