Bonjour à tous,
J'ai un petit problème que je ne comprends pas sur mon application.
Je vais essayer d'être le plus clair possible malgré le fait que je ne peux pas trop en dire
J'utilise EntityFramework via LinqToEntities et Npgsql (provider PostgreSQL).
J'ai besoin de récupérer des données dans plusieurs de mes tables en un seul coup.
Je fais donc quelque chose comme ceci.
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 Db = new PostgresqlGecoContext(); Db.Connection.Open(); var query = Db.table1 .Include("table2") .Include("table3") .Include("table4") .Include("table5") .Include("table6") .Include("table4") .Include("table7") .Include("table4.table8") .Include("table4.table9") .Include("table4.table10") .Include("table4.table10.table11");
Ok. J'ai le bon nombre de résultat, et tout est OK
Par contre quand je rajoute d'autre Include(), j'ai une erreur qui apparait.
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 Db = new PostgresqlGecoContext(); Db.Connection.Open(); var query = Db.table1 .Include("table2") .Include("table3") .Include("table4") .Include("table5") .Include("table6") .Include("table4") .Include("table7") //table4 .Include("table4.table8") .Include("table4.table9") .Include("table4.statut") .Include("table4.table12") .Include("table4.table12.table13") .Include("table4.table12.table14") .Include("table4.table12.table15") .Include("table4.table12.table16") .Include("table4.table12.table17") .Include("table4.table12.table18") .Include("table4.table10") .Include("table4.table10.table11");
Voici l'erreur:
A first chance exception of type 'System.Data.EntityCommandCompilationException' occurred in System.Data.Entity.dll
Si j'enlève les include si dessous, je n'ai plus l'erreur.
Ce qui est étonnant c'est que dans le 1er exemple je l'avais et ça ne bug pas.
Code c# : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3 .Include("table4.table10") .Include("table4.table10.table11");
On dirait que c'est la combinaison de certain include qu'il n'aime pas.
Je sais que ce n'est pas évident de répondre comme ça, mais est ce que quelqu'un à une idée d'une cause possible?
Si vous avez des pistes ça m'intérèsse beaucoup.
Y a t('il un moyen de faire différement sinon?
Un grand merci.
Partager