2 years ago
#45715
Anderson Paolo
The 'Collate' method is not supported because the query has switched to client-evaluation
I am new to .net 6. I wanted to test with Xunit a method with an explicit collation in a LINQ query . When I try to test this method , i have this error : "The 'Collate' method is not supported because the query has switched to client-evaluation. This usually happens when the arguments to the method cannot be translated to server. Rewrite the query to avoid client evaluation of arguments so that method can be translated to server."
My methode :
public async Task<IEnumerable<DjAggregatePerson>> RecherchePhysiqueAsync(string? nom, string? prenom, string? nomJeuneFille, string? dateNaissance, string? sexe, string? villeNaissance, string? paysNaissance)
{
var gda = from m in _LCBFTContext.DjAggregatePeople
select m;
if (!String.IsNullOrEmpty(nom))
{
if (nom.StartsWith('*') && !nom.EndsWith('*'))
{
string customNom = ParametrizedSearch.RemoveAsterix(nom, '*');
gda = gda.Where(s => EF.Functions.Collate(s.PrimarySurname, "SQL_Latin1_General_CP1_CI_AI").EndsWith(customNom));
}
return await gda
.AsNoTracking()
.OrderByDescending(s => s.PrimarySurname).ThenByDescending(s => s.PrimaryFirstName)
.ToListAsync();
}
My test :
public async Task Should_get_data()
{
var result = await _ppeRepo.RecherchePhysiqueAsync("Dupon",null, null, null, null, null, null);
result.ShouldNotBeNull();
}
Error :
The 'Collate' method is not supported because the query has switched to client-evaluation. This usually happens when the arguments to the method cannot be translated to server. Rewrite the query to avoid client evaluation of arguments so that method can be translated to server.
entity-framework-core
xunit.net
.net-6.0
0 Answers
Your Answer