2012-06-29 177 views
5

運行此Linq查詢時,我得到一個「NotSupportedException」。 「不支持指定的方法。」什麼方法?即使「Count()」被註釋掉了,錯誤也是一樣的。空內部例外。NotSupportedException與linq查詢和groupBy

堆棧跟蹤:

在Hydra.WPF.ViewModels.AddressListViewModel._primaryMemberListWorker_DoWork(對象 發件人,DoWorkEventArgs e)如 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

哪條線是1377? – walther

+6

Hibernate的linq實現對基本操作符有問題。我想知道我們什麼時候才能最終得到體面的實現...... –

+0

1377只是調用存儲此方法的存儲庫方法。 – Seraph812

回答

0

你如何產生的標準變量?如果這本身就是一個推遲的查詢或其他東西,它聽起來像是可能的罪魁禍首。如果在查詢之前執行var criteriaId = criteria.AddressList.Id;,會發生什麼情況,併爲您的查詢提供criteriaId而不是criteria.AddressList.Id?