我想在entityframework core 3.1中执行查询
我的问题是:
return await context_client.Tbcategoriapregunta.Include(e => e.Tbpreguntasfrecuentes.Where(preguntas => preguntas.Dstipousuario == user)).ToListAsync();
但不起作用,这是消息错误
Lambda expression used inside Include is not valid.
这是数据元素消息堆栈跟踪
在microsoft.entityframeworkcore.query.internal.NavigationExpansionExpressionVisitor.processinclude(navigationexpansionexpression源,表达式,位于system.linq.expressions.methodcallexpression.accept(expressionvisitor)的microsoft.entityframeworkcore.query.internal.navigationexpandingexpressionvisitor.VisitMethodCallExpression(methodcallexpression methodcallexpression)调用microsoft.entityframeworkcore.query.internal.navigationexpandingexpressionvisitor.expand(expression query)at microsoft.entityframeworkcore.query.querytranslationpreprocessor.process(expression query)at microsoft.entityframeworkcore.query.querycompilationcontext.createqueryexecutor[tresult](表达式查询)at位于microsoft.entityframeworkcore.query.internal.querycompiler.CompileryCore[tresult](idatabase database,expression query,imodel model,boolean async)的microsoft.entityframeworkcore.query.internal.querycompiler.CompileryCore[tresult](idatabase database,expression query,imodel model,boolean async)。c\u displayclass12\u 0 1.<ExecuteAsync>b__0() at Microsoft.EntityFrameworkCore.Query.Internal.CompiledQueryCache.GetOrAddQueryCore[TFunc](Object cacheKey, Func
1编译器)位于microsoft.entityframeworkcore.query.internal.compiledquerycache.getoraddquery[tresult](对象缓存键,函数 1 compiler) at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.ExecuteAsync[TResult](Expression query, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.ExecuteAsync[TResult](Expression expression, CancellationToken cancellationToken) at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable
1.位于microsoft.entityframeworkcore.entityframeworkqueryableextensions.includablequeryable的getasyncenumerator(cancellationtoken cancellationtoken) 2.GetAsyncEnumerator(CancellationToken cancellationToken) at System.Runtime.CompilerServices.ConfiguredCancelableAsyncEnumerable
1.位于microsoft.entityframeworkcore.entityframeworkqueryableextensions.d\u 64的getasyncenumerator() 1.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter
1.c:\users\admin\source\repos\api013 ayuda\business\implementation\bscategoriapregunta.d\uu 4.movenext()中的business.implementation.bscategoriapregunta.d\u 4.getresult():第58行
有什么想法。。。???
1条答案
按热度按时间tzxcd3kk1#
目的
Include()
是告诉它在处理此查询的同时从相关表加载数据。文档中的示例使用了一个场景,您希望从数据库中加载博客列表,并包括与每个博客相关的帖子:
所以有一个
Where()
内部Include()
.你得告诉我们你想做什么。但也许这样的办法行得通?