try fixup search

This commit is contained in:
honzapatCZ 2024-09-24 16:59:15 +02:00
parent f61f9e7cb1
commit 0346a448c4

View File

@ -55,7 +55,10 @@ public static class Extensions
} }
var extPar = Expression.Parameter(typeof(TType)); var extPar = Expression.Parameter(typeof(TType));
var binder = (TEntityBinder)typeof(TEntityBinder).GetConstructor(new[] { typeof(DbContext) })!.Invoke(new object?[] { null });
using (var scope = providers.CreateScope())
{
var binder = scope.ServiceProvider.GetRequiredService<TEntityBinder>();
var idMatcher = binder.RouteValues.First(x => x.Primary).Expression; var idMatcher = binder.RouteValues.First(x => x.Primary).Expression;
var reducedIdMatcher = Expression.Lambda<Func<TType, bool>>(Expression.Invoke(idMatcher, extPar, Expression.Constant(search)).Reduce(), extPar); var reducedIdMatcher = Expression.Lambda<Func<TType, bool>>(Expression.Invoke(idMatcher, extPar, Expression.Constant(search)).Reduce(), extPar);
//Console.Writeline(reducedIdMatcher); //Console.Writeline(reducedIdMatcher);
@ -84,6 +87,7 @@ public static class Extensions
//Console.Writeline(orLambda); //Console.Writeline(orLambda);
query = query.Where(orLambda); query = query.Where(orLambda);
} }
}
return await query.ApplyPaginationRes<TType, TResponseType>(providers, pag); return await query.ApplyPaginationRes<TType, TResponseType>(providers, pag);
} }