RavenDB中的日期查询问题



当试图将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(),

可查询时。Count()被调用时抛出异常。从异常中查看url,似乎会生成"Date:2012-08-22T0:00.0000000000"作为查询参数,然后RavenDB客户端将"22T00:"解释为索引中的新字段名。

System.InvalidOperationException未由用户代码处理消息=Url:"/indexes/VisitsByMediaSourceAndVersion?query=日期%253A2012-08->22T00%253A00%253A000000000&start=0&pageSize=0&aggregation=None">

为什么会这样?附近有工作吗?我是唯一一个有这个问题的人吗?

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

使用RavenDB客户端1.2.0.0和服务器960。

感谢所有的帮助!

全栈跟踪:

用户代码未处理System.InvalidOperationException消息=Url:"/indexes/VisitsByMediaSourceAndVersion?query=日期%253A2012-08-22T00%253A00%253A00.0000000000&start=0&pageSize=0&paggregation=None">

System.ArgumentException:字段"22T00"未编入索引,无法对未编入索引的字段进行查询位于Raven.Database.Inding.Index.IndexQueryOperation.AsserQueryDoesNotContainFieldsThatAreNotIndexes(),位于c:\Builds\RavenDB Stable\Raven.Database\Inding\Index.cs:line 819位于Raven.Database.Inding.Index.IndexQueryOperation.d2e.MoveNext(),位于c:\Builds\RavenDB Stable\Raven.Database\Inding\Index.cs:line 635位于System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()位于System.Collections.Generic.List1.InsertRange(Int32 index, IEnumerable1集合)位于Raven.Database.DocumentDatabase。<>c:\Builds\RavenDB Stable\Raven.Database\DocumentDatabase.cs:line 838中的c_DisplayClass82.b_78(IStorageActionsAccessor操作)位于c:\Builds\RavenDB Stable\Raven.Storage.Esent.TransactionalStorage.ExecuteBatch(操作1 action) in c:BuildsRavenDB-StableRaven.Storage.EsentTransactionalStorage.cs:line 376 at Raven.Storage.Esent.TransactionalStorage.Batch(Action1操作)位于Raven.Database.DocumentDatabase.Query(字符串索引,IndexQuery查询),位于c:\Builds\RavenDB Stable\Raven.Database\DocumentDatabase.cs:line 781位于Raven.Database.Server.Responders.Index.PerformQueryAgainstExistingIndex(IHttpContext context,String Index,IndexQuery IndexQuery,Guid&indexEtag),位于c:\Builds\RavenDB Stable\Raven.Database\Server\Responders\Index.cs:line 214位于Raven.Database.Server.Responders.Index.ExecuteQuery(IHttpContext上下文,字符串索引,Guid&indexEtag),位于c:\Builds\RavenDB Stable\Raven.Database\Server\Responders\Index.cs:line 179位于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:line 91位于Raven.Database.Server.Responders.Index.Respond(IHttpContext上下文),位于c:\Builds\RavenDB Stable\Raven.Database\Server\Responders\Index.cs:line 46位于Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx),位于c:\Builds\RavenDB Stable\Raven.Database\Server\HttpServer.cs:line 550位于Raven.Database.Server.HttpServer.HHandleActualRequest(IHttpContext ctx),位于c:\Builds\RavenDB Stable\Raven.Database\Server\HttpServer.cs:line 316

来源=Raven.Client.LightweightStackTrace:位于Raven.Client.Connection.HttpJsonRequest.HandleErrors(WebException e),位于c:\Builds\RavenDB-Unstable-v1.2\Raven.Customer.Lightweight\Connection\HttpJsonRequest.cs:line 422位于Raven.Client.Connection.HttpJsonRequest.ReadJsonInternal(函数1 getResponse) in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightConnectionHttpJsonRequest.cs:line 292 at Raven.Client.Connection.HttpJsonRequest.ReadResponseJson() in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightConnectionHttpJsonRequest.cs:line 202 at Raven.Client.Connection.ServerClient.DirectQuery(String index, IndexQuery query, String operationUrl, String[] includes) in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightConnectionServerClient.cs:line 745 at Raven.Client.Connection.ServerClient.<>c__DisplayClass43.<Query>b__42(String u) in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightConnectionServerClient.cs:line 727 at Raven.Client.Connection.ReplicationInformer.TryOperation[T](Func2操作,字符串operationUrl,布尔避免抛出,T&result),位于c:\Builds\RavenDB-Unstable-v1.2\Raven.Customer.Lightweight\Connection\ReplicationInformer.cs:line 548在Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication[T](字符串方法,字符串primaryUrl,Int32 currentRequest,Int32 currentReadStripingBase,Func2 operation) in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightConnectionReplicationInformer.cs:line 520 at Raven.Client.Connection.ServerClient.ExecuteWithReplication[T](String method, Func2操作)中,位于c:\Builds\RavenDB-Unstable-v1.2\Raven.Customer.Lightweight\Connection\ServerClient.cs:line 165位于Raven.Client.Connection.ServerClient.Query(字符串索引,IndexQuery查询,String[]包含),位于c:\Builds\RavenDB-Unstable-v1.2\Raven.Customer.Lightweight\Connection\ServerClient.cs:line 727位于Raven.Client.Document.AbstractDocumentQuery2.ExecuteActualQuery() in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightDocumentAbstractDocumentQuery.cs:line 462 at Raven.Client.Document.AbstractDocumentQuery2.InitSync(),位于c:\Builds\RavenDB-Unstable-v1.2\Raven.Customer.Lightweight\Document\AbstractDocument Query.cs:line 444在Raven.Client.Document.AbstractDocumentQuery2.get_QueryResult() in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightDocumentAbstractDocumentQuery.cs:line 430 at Raven.Client.Linq.RavenQueryProviderProcessor1.GetQueryResult[TProjection](IDocumentQuery1 finalQuery) in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightLinqRavenQueryProviderProcessor.cs:line 1456 at Raven.Client.Linq.RavenQueryProviderProcessor1.ExecuteQueryTProjection in c:\Builds\RavenDB-Unstable-v1.2\Raven.Customer.Lightweight\Linq\RavenQueryProviderProcessor.cs:line 1376位于Raven.Client.Linq.RavenQueryProviderProcessor1.Execute(Expression expression) in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightLinqRavenQueryProviderProcessor.cs:line 1359 at Raven.Client.Linq.RavenQueryProvider1.在c:\Builds\RavenDB-Unstable-v1.2\Raven.Customer.Lightweight\Linq\RavenQueryProvider.cs:line 138中执行(表达式)位于Raven.Client.Linq.RavenQueryProvider1.System.Linq.IQueryProvider.Execute[S](Expression expression) in c:BuildsRavenDB-Unstable-v1.2Raven.Client.LightweightLinqRavenQueryProvider.cs:line 183 at System.Linq.Queryable.Count[TSource](IQueryable1来源)位于TotalyMoney.CreditCards.Admin.Web.Controllers.DailyReportController.Report(ReportPostModel ReportPostModel),位于C:\Development\Git\MediaIngenuity\TotalyMony.CreditCards\TotalyMonie.CreditCards.Admin.Web\Controllers\DailyReportController。cs:line 33在lambda_method(闭包、ControllerBase、Object[])位于System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,Object[]参数)位于System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext ControllerContext,IDictionary2 parameters) at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2参数)位于System.Web.Mvc.ControllerActionInvoker。<>c_显示类15.b_12()位于System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter筛选器,ActionExecutingContext preContext,Func`1 continuation)内部异常:

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

您可以使用较旧的客户端和较新的服务器,但不能使用其他方式。

如果它正在生成正确的日期,并且之后不需要其余数据,您可以使用子字符串只提取日期吗,或者可能在可查询的方法周围使用GetDate()。计数()?

相关内容

  • 没有找到相关文章

最新更新