Hi everyone,
I have a little problem with my where clause. I work with entity framework 7 update 1.
Here is my context :
I have 2 entities (Dossier and Assiette). My entity Dossier contains a collection of Assiette and my entity Assiette contains only one Dossier.
For each entity Assiette, I have a year property, named "AnneeImputation".
Here is my code to filter my entities :
IQueryable<DossierModel> query = dbSet; query = query.Where(dos => dos.NumeroMatricule == matricule && dos.CleMatricule == cleMatricule && dos.Assiettes.Any(x => x.AnneeImputation == anneeImputation));
return query.FirstOrDefault();
I don't know why the query generated by entity framework is not correct :
SELECT TOP(1) <...> FROM [APPL_GARP].[T_DOS_DOSSIER] AS [dos] WHERE (([dos].[DOS_NUMMAT] = @__matricule_0) AND ([dos].[DOS_CLEMAT] = @__cleMatricule_1)) AND ( SELECT CASE WHEN EXISTS ( SELECT 1 FROM [APPL_GARP].[T_ASS_ASSIETTE] AS [x] WHERE ([x].[ASS_ANNEE_IMPUT] = @__anneeImputation_2) AND ([dos].[DOS_ID] = [x].[DOS_ID])) THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT) END )
Do you know why my "Any" into filter is wrong ?
Any help will be appreciate.
Greg