gpt4 book ai didi

datetime - RavenDB中日期查询的问题

转载 作者:行者123 更新时间:2023-12-03 06:33:38 24 4
gpt4 key购买 nike

当试图在我的应用程序中比较MapReduce中的日期属性时,我得到了奇怪的行为。

var queryDate = DateTime.Now.Date;
IQueryable<VisitsByMediaSourceAndVersion.MapReduceResult> queryable =
_documentSession
.Query<MyIndex.MapReduceResult>(MyIndex.INDEX_NAME)
.Where(mapReduceResult => mapReduceResult.Date == queryDate);
var count = queryable.Count(),


调用queryable.Count()时,将引发异常。从异常中查看url,似乎生成了“ Date:2012-08-22T00:00:00.0000000”作为查询参数,然后RavenDB客户端将“ 22T00:”解释为索引中的新字段名称。


用户代码未处理System.InvalidOperationException
消息=网址:“ / indexes / VisitsByMediaSourceAndVersion?query = Date%253A2012-08-> 22T00%253A00%253A00.0000000&start = 0&pageSize = 0&aggregation = None”


为什么是这样?有没有解决的办法?我是唯一有这个问题的人吗?

我无法在RavenDB的EmbeddableDocumentStore版本中重新创建此问题,这有意义吗?如果删除日期查询,它将返回结果,因此索引本身可以工作。

使用RavenDB Client 1.2.0.0和Server 960。

感谢所有帮助!

完整堆栈跟踪:

用户代码未处理System.InvalidOperationException
消息=网址:“ / indexes / VisitsByMediaSourceAndVersion?query = Date%253A2012-08-22T00%253A00%253A00.0000000&start = 0&pageSize = 0&aggregation = None”

System.ArgumentException:字段'22T00'未建立索引,无法查询未建立索引的字段
在c:\ Builds \ RavenDB-Stable \ Raven.Database \ Indexing \ Index.cs:line 819中的Raven.Database.Indexing.Index.IndexQueryOperation.AssertQueryDoesNotContainFieldsThatAreNotIndexes()
在c:\ Builds \ RavenDB-Stable \ Raven.Database \ Indexing \ Index.cs:line 635中的Raven.Database.Indexing.Index.IndexQueryOperation.d_2e.MoveNext()
在System.Linq.Enumerable.WhereSelectEnumerableIterator 2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()
在System.Collections.Generic.List 1.InsertRange(Int32 index, IEnumerable 1集合中)
在Raven.Database.DocumentDatabase中。<> c_DisplayClass82.b__78(IStorageActionsAccessor操作)在c:\ Builds \ RavenDB-Stable \ Raven.Database \ DocumentDatabase.cs:line 838中
在c:\ Builds \ RavenDB-Stable \ Raven.Storage.Esent \ TransactionalStorage.cs:line 337中的Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(Action 1 action) in c:\Builds\RavenDB-Stable\Raven.Storage.Esent\TransactionalStorage.cs:line 376
at Raven.Storage.Esent.TransactionalStorage.Batch(Action
1 action)
在C:\ Builds \ RavenDB-Stable \ Raven.Database \ DocumentDatabase.cs:line 781中的Raven.Database.DocumentDatabase.Query(字符串索引,IndexQuery查询)处
在Raven.Database.Server.Responders.Index.PerformQueryAgainstExistingIndex(IHttpContext上下文,字符串索引,IndexQuery indexQuery,Guid和indexEtag)位于c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs:line 214
在C:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs:line 179中的Raven.Database.Server.Responders.Index.ExecuteQuery(IHttpContext上下文,字符串索引,Guid和indexEtag)
在Raven.Database.Server.Responders.Index.GetIndexQueryRessult(IHttpContext上下文,字符串索引)在c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs:line 119
在Raven.Database.Server.Responders.Index.OnGet(IHttpContext上下文,字符串索引)中的c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs:第91行
在c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs:第46行中的Raven.Database.Server.Responders.Index.Respond(IHttpContext上下文)
在C:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ HttpServer.cs:line 550中的Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx)
在C:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ HttpServer.cs:line 316中的Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx)

来源= Raven.Client.Lightweight
堆栈跟踪:
在c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Connection \ HttpJsonRequest.cs:line 422中的Raven.Client.Connection.HttpJsonRequest.HandleErrors(WebException e)
在C:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Connection \ ReplicationInformer中的Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(Func 1 getResponse) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 292
at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\HttpJsonRequest.cs:line 202
at Raven.Client.Connection.ServerClient.DirectQuery(String index, IndexQuery query, String operationUrl, String[] includes) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:line 745
at Raven.Client.Connection.ServerClient.<>c__DisplayClass43.<Query>b__42(String u) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ServerClient.cs:line 727
at Raven.Client.Connection.ReplicationInformer.TryOperation[T](Func
2操作,String operationUrl,布尔避免抛出,T&结果) .cs:第548行
在C:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client中的Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication [T](字符串方法,字符串primaryUrl,Int32 currentRequest,Int32 currentReadStripingBase,Func 2 operation) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Connection\ReplicationInformer.cs:line 520
at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func
2操作)处.Lightweight \ Connection \ ServerClient.cs:第165行
在C:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Connection \ ServerClient.cs:line 727中的Raven.Client.Connection.ServerClient.Query(字符串索引,IndexQuery查询,String []包括)处
在c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Document \ AbstractDocumentQuery.cs:line 444中的Raven.Client.Document.AbstractDocumentQuery 2.ExecuteActualQuery() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 462
at Raven.Client.Document.AbstractDocumentQuery
2.InitSync()
在Raven.Client.Document.AbstractDocumentQuery 2.get_QueryResult() in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 430
at Raven.Client.Linq.RavenQueryProviderProcessor
1.GetQueryResult [TProjection](IDocumentQuery 1 finalQuery) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1456
at Raven.Client.Linq.RavenQueryProviderProcessor
1.ExecuteQueryTProjection在c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Linq \ RavenQueryProviderProcessor.cs中:行1376
在C:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Linq \ RavenQueryProvider.cs:line 138中的Raven.Client.Linq.RavenQueryProviderProcessor 1.Execute(Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1359
at Raven.Client.Linq.RavenQueryProvider
1.Execute(表达式表达式)处
在Raven.Client.Linq.RavenQueryProvider 1.System.Linq.IQueryProvider.Execute[S](Expression expression) in c:\Builds\RavenDB-Unstable-v1.2\Raven.Client.Lightweight\Linq\RavenQueryProvider.cs:line 183
at System.Linq.Queryable.Count[TSource](IQueryable
1源)
在TotallyMoney.CreditCards.Admin.Web.Controllers.DailyReportController.Report(ReportPostModel reportPostModel)在C:\ Development \ Git \ MediaIngenuity \ TotallyMoney.CreditCards \ TotallyMoney.CreditCards.Admin.Web \ Controllers \ DailyReportController.cs:line 33中
在lambda_method(Closure,ControllerBase,Object [])
在System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,Object []参数)
在System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary 2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2个参数)
在System.Web.Mvc.ControllerActionInvoker。<> c_DisplayClass15.b_12()
在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter过滤器,ActionExecutingContext preContext,Func`1延续)处
InnerException:

最佳答案

发生此异常的原因是,您使用的是针对1.0服务器的1.2(现在为2.0)客户端。不支持。

您可以将较旧的客户端与更新的服务器一起使用,但反之则不能。

关于datetime - RavenDB中日期查询的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12077055/

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