Linq To Entities uygulamasında çoktan çoğa ilişkileri sorgulamada sorun yaşıyorum. Temelde Linq kullanarak bu sorguyu çoğaltmak çalışıyorum: Ben net etrafında baktım ve gerçekten bunun nasıl herhangi uygun örnekleri bulunmayanEntity Framework - Varlıklara Linq - Çoktan Çok Sorgu Sorunları
Select *
FROM Customer
LEFT JOIN CustomerInterest ON Customer.CustomerID = CustomerInterest.CustomerID
LEFT JOIN Interest ON CustomerInterest.InterestID = Interest.InterestID
WHERE Interest.InterestName = 'Football'
. Ben var en yakın olan: bununla
List<Customer> _Customers = (from _LCustomers in _CRM.Customer.Include("CustomerInterest.Interest")
where _LCustomers.CustomerInterest.Any(x => x.Interest.InterestName == "Football")
select _LCustomers).ToList();
problem müşteri birden fazla ilgi varsa olmasıdır ve bunlardan biri hepsini iade edilir ardından "Futbol" dir. Tersine problemi olan All() 'a da baktım, yani sadece bir ilgisi varsa ve futbol varsa geri dönecekler, eğer iki tane varsa ve bunlardan biri futbol olmazsa hiçbir şey iade edilmez.
Herhangi bir fikri olan var mı?
bu soruya bakınız - http://stackoverflow.com/questions/1535443 ve bu yayını - http://blogs.msdn.com/b/alexj/archive/2009/10/13/tip -37-how-to-do-a-koşullu-include.aspx. – Kniganapolke