gpt4 book ai didi

ravendb - 按 RavenDB 中的整数列表排序

转载 作者:行者123 更新时间:2023-12-04 01:07:17 28 4
gpt4 key购买 nike

我正尝试在 RavenDB 中检索我按 int 列表排序的文档。

Queryable = Queryable.OrderBy(dto => SearchIds.IndexOf(dto.PropertyId));

上面的代码是我从这个 post 中找到的解决方案.

但是,当客户端需要解析 LINQ to RQL 时,它会返回错误。

System.InvalidOperationException: Cannot understand how to translate value(infrastructure.DataAccess.HolidayHome.Filtering.PropertyInformationFilteringService).SearchIds.IndexOf(dto.PropertyId)
at Raven.Client.Documents.Linq.LinqPathProvider.GetPath(Expression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\LinqPathProvider.cs:line 114
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.GetMemberDirect(Expression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 554
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitOrderBy(LambdaExpression expression, Boolean descending) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 2263
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitQueryableMethodCall(MethodCallExpression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 1914
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitMethodCall(MethodCallExpression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 1204
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitExpression(Expression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 202
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitQueryableMethodCall(MethodCallExpression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 1802
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitMethodCall(MethodCallExpression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 1204
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitExpression(Expression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 202
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitQueryableMethodCall(MethodCallExpression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 1808
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitMethodCall(MethodCallExpression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 1204
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.VisitExpression(Expression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 202
at Raven.Client.Documents.Linq.RavenQueryProviderProcessor`1.GetAsyncDocumentQueryFor(Expression expression, Action`1 customization) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProviderProcessor.cs:line 3518
at Raven.Client.Documents.Linq.RavenQueryProvider`1.ToAsyncDocumentQuery[TResult](Expression expression) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\Linq\RavenQueryProvider.cs:line 258
at Raven.Client.Documents.LinqExtensions.ToListAsync[T](IQueryable`1 source, CancellationToken token) in C:\Builds\RavenDB-Stable-5.0\50009\src\Raven.Client\Documents\LinqExtensions.cs:line 313
at infrastructure.DataAccess.HolidayHome.Filtering.PropertyInformationFilteringService.FilterBySearchCriteria() in C:\Users\Alex\git\search-service\infrastructure\DataAccess\HolidayHome\Filtering\PropertyInformationFilteringService.cs:line 31
at infrastructure.DataAccess.HolidayHome.Commands.Property.PropertyInfoCommands.GetPropertyDtos(SearchResultCriteria searchCriteria, List`1 searchIds) in C:\Users\Alex\git\search-service\infrastructure\DataAccess\HolidayHome\Commands\Property\PropertyInfoCommands.cs:line 29
at webapi.Controllers.v1.SearchController.RetrieveSearch(SearchResultCriteria searchResultCriteria) in C:\Users\Alex\git\search-service\web-api\Controllers\v1\SearchController.cs:line 265
at webapi.Controllers.v1.SearchController.Get(SearchResultCriteria searchResultCriteria) in C:\Users\Alex\git\search-service\web-api\Controllers\v1\SearchController.cs:line 67
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Awaited|12_0(ControllerActionInvoker invoker, ValueTask`1 actionResultValueTask)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|19_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)

有没有更好的方法来按整数列表排序?

最佳答案

请参阅以下示例以对查询结果进行排序:
https://demo.ravendb.net/demos/csharp/queries/sorting-query-results

您使用 OrderByDescendingOrderBy()
定义查询请参阅:https://demo.ravendb.net/demos/csharp/queries/sorting-query-results#step-3

还可以使用二级排序:
请参阅:https://demo.ravendb.net/demos/csharp/queries/sorting-query-results#step-4

关于ravendb - 按 RavenDB 中的整数列表排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66029408/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com