benim LINQ sorgusunda bir satır içi tablo değerli işlev içeren bir tablo katılmak dış çalışılıyor ama zamanında bir sorgu derleme hatası alıyorum:Varlık Çerçeve 5: Nasıl dış birleşim Tablo değerli işlev
" Sorgu, iç içe bir sorgu üzerinde 'OuterApply' çağırmaya çalıştı, ancak 'OuterApply' uygun anahtarlara sahip değildi. "
Benim linq deyimi şuna benzer:
CREATE FUNCTION dbo.UFN_AccountAdvisorsConcatenated_Get()
RETURNS TABLE
AS
RETURN
SELECT AP.AccountId,
LEFT(AP.Advisors, LEN(AP.Advisors) - 1) AS Advisors
FROM ( SELECT DISTINCT
AP.AccountId,
( SELECT AP2.PropertyValue + ', '
FROM dbo.AccountProperty AP2 WITH (NOLOCK)
WHERE AP2.AccountId = AP.AccountId
AND AP2.AccountPropertyTypeId = 1 -- Advisor
FOR XML PATH('')) AS Advisors
FROM dbo.AccountProperty AP WITH (NOLOCK)) AP;
başarıyla aşağıdaki gibi sql doğrudan katılmak gerçekleştirebilirsiniz: şu şekildedir:
var testQuery = (from accountBase in ViewContext.AccountBases
join advisorConcatRaw in ViewContext.UFN_AccountAdvisorsConcatenated_Get()
on accountBase.AccountId equals advisorConcatRaw.AccountId into advisorConcatOuter
from advisorConcat in advisorConcatOuter.DefaultIfEmpty()
select new
{
accountBase.AccountId,
advisorConcat.Advisors
}).ToList();
fonksiyon tanımıdır
SELECT ab.accountid,
advisorConcat.Advisors
FROM accountbase ab
LEFT OUTER JOIN dbo.Ufn_accountadvisorsconcatenated_get() advisorConcat
ON ab.accountid = advisorConcat.accountid
İç dış hatlarda bir satır içi birleştirme örneği var mı? LINQ içinde bir tabloya TVF varlıklar - veya bu bilinen bir kusur, vb? Çok teşekkürler.
Aynı sorun var mı, herhangi bir çözüm? –
Yine de buna Microsoft'tan yanıt gelmiyor - bu sorun EF'nin sonraki sürümünde düzeltilecek mi? –