Bu sorun ile sıkışmış durumdayım. Umarım biraz yardım edeceğim. İşte nokta. O SQL isteği ile benim DataGridView doldurmak zorunda yer:Kullanılamıyor Linq ile Linq nedeniyle <AnonymousType>
SELECT LOT.NumLot, EtatLot, NomEmploye FROM LOT
JOIN AFFECTATION_LOT on LOT.NumLot=AFFECTATION_LOT.NumLot
JOIN EMPLOYE on AFFECTATION_LOT.IdEmploye=EMPLOYE.IdEmploye
WHERE EtatLot='Libéré' or EtatLot='Suspendu' or EtatLot='Démarré'
UNION
SELECT NumLot, EtatLot, null FROM LOT
WHERE EtatLot='Démarré'
İlk ben kullandım "boş" değeri benim ikinci "BİRLİĞİ" gibi 3 argümanları olması gerekir, çünkü "SEÇ" ilk "SEÇ" ve Tablo LOT'umda "NomEmploye" verisi yok. Neyse, bu istek SQL'de iyi çalışıyor. Ama LINQ
string test = "null";
var listeLotControle = (from x in entBoum.LOT
join aff in entBoum.AFFECTATION_LOT on x.NumLot equals aff.NumLot
join emp in entBoum.EMPLOYE on aff.IdEmploye equals emp.IdEmploye
where x.EtatLot.Contains("Libéré") || x.EtatLot.Contains("Suspendu") || x.EtatLot.Contains("Démarré")
select new { x.NumLot, x.EtatLot, emp.NomEmploye }).Union
(from x in entBoum.LOT
where x.EtatLot.Contains("Démarré")
select new { x.NumLot, x.EtatLot, test });
dataGridViewAffectationLotControleur.DataSource = listeLotControle.ToList();
kullanmak çalıştığımda 3 Visual Studio hataları ve ben gerçekten yok bunu anlamak o var.
Error 1 Argument instance: can not convert 'System.Linq.IQueryable AnonymousType # 1>' to 'System.Linq.ParallelQuery <AnonymousType # 2>'
Error 2 'System.Linq.IQueryable <AnonymousType # 1>' does not contain a definition for 'Union' and the best overload the extension method 'System.Linq.ParallelEnumerable.Union <TSource> (System.Linq.ParallelQuery <TSource>, System.Collections.Generic.IEnumerable <TSource>) '
Error 3 type arguments for method 'System.Linq.Enumerable.ToList <TSource> (System.Collections.Generic.IEnumerable <TSource>)' can not be inferred from the use. Try specifying the type arguments explicitly.
i görebileceğiniz gibi
, sorunun<AnonymousType>
kaynaklanmaktadır .... Ama o kadar çok şu an bana yardım etmez. Ben de o
IQueryable listeLotControle;
string test = "null";
listeLotControle = (from x in entBoum.LOT
join aff in entBoum.AFFECTATION_LOT on x.NumLot equals aff.NumLot
join emp in entBoum.EMPLOYE on aff.IdEmploye equals emp.IdEmploye
where x.EtatLot.Contains("Libéré") || x.EtatLot.Contains("Suspendu") || x.EtatLot.Contains("Démarré")
select new { x.NumLot, x.EtatLot, emp.NomEmploye }).Union
(from x in entBoum.LOT
where x.EtatLot.Contains("Démarré")
select new { x.NumLot, x.EtatLot, test });
dataGridViewAffectationLotControleur.DataSource = listeLotControle.ToList();
çalışmak Ama aynı hataları var olmak için bir yol artı bu bir
belki bir kullanma ihtiyacımama hangisi denedim? (Zaten ben)
Son olarak, bu son yöntemi denedim.
string test = "null";
var listeLotControle = from x in entBoum.LOT
join aff in entBoum.AFFECTATION_LOT on x.NumLot equals aff.NumLot
join emp in entBoum.EMPLOYE on aff.IdEmploye equals emp.IdEmploye
where x.EtatLot.Contains("Libéré") || x.EtatLot.Contains("Suspendu") || x.EtatLot.Contains("Démarré")
select new { x.NumLot, x.EtatLot, emp.NomEmploye };
var listeLotControle2 = from x in entBoum.LOT
where x.EtatLot.Contains("Démarré")
select new { x.NumLot, x.EtatLot, test };
var union = listeLotControle.Union(listeLotControle2);
dataGridViewAffectationLotControleur.DataSource = listeLotControle2.ToList();
Ama hala o büyük blok için bu hatalar
Error 1 'System.Linq.IQueryable <AnonymousType # 1>' does not contain a definition for 'Union' and the best overload the extension method 'System.Linq.ParallelEnumerable.Union <TSource> (System.Linq.ParallelQuery <TSource>, System.Collections.Generic.IEnumerable <TSource>) 'contains invalid arguments
Error 2 Argument instance: can not convert 'System.Linq.IQueryable <AnonymousType # 1>' to 'System.Linq.ParallelQuery <AnonymousType # 2>'
Üzgünüz var ama seni istemeden önce ben ne yaptığını tüm açıklamaya çalıştık. Gelecekte vereceğiniz cevaplar için teşekkürler. Sadece son denemede baktığımızda
İyi ilk kez soru! – Enigmativity