当我尝试将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()时,抛出异常。看看例外的网址似乎&#34;日期:2012-08-22T00:00:00.0000000&#34;生成为查询参数,然后RavenDB-client解释&#34; 22T00:&#34;作为索引中的新字段名称。
System.InvalidOperationException未被用户代码处理 Message = Url:&#34; / indexes / VisitsByMediaSourceAndVersion?query = Date%253A2012-08-&gt; 22T00%253A00%253A00.0000000&amp; start = 0&amp; pageSize = 0&amp; aggregation = None&#34;
这是为什么?有工作吗?我是唯一有这个问题的人吗?
我无法在RavenDB的EmbeddableDocumentStore版本中重新创建此问题,这有意义吗?如果我删除了日期查询,它会返回结果,因此索引本身就可以工作。
使用RavenDB客户端1.2.0.0和服务器960。
感谢所有人的帮助!
完整堆栈跟踪:
System.InvalidOperationException未被用户代码处理 Message = Url:&#34; / indexes / VisitsByMediaSourceAndVersion?query = Date%253A2012-08-22T00%253A00%253A00.0000000&amp; start = 0&amp; pageSize = 0&amp; aggregation = None&#34;
System.ArgumentException:字段&#39; 22T00&#39;未编入索引,无法查询未编制索引的字段
at Raven.Database.Indexing.Index.IndexQueryOperation.AssertQueryDoesNotContainFieldsThatAreNotIndexes()in c:\ Builds \ RavenDB-Stable \ Raven.Database \ Indexing \ Index.cs:line 819
at Raven.Database.Indexing.Index.IndexQueryOperation.d_ 2e.MoveNext()in c:\ Builds \ RavenDB-Stable \ Raven.Database \ Indexing \ Index.cs:line 635
在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。&lt;&gt; c _DisplayClass82.b__78(IStorageActionsAccessor actions)中的c:\ Builds \ RavenDB-Stable \ Raven.Database \ DocumentDatabase.cs:第838行
at 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)in c:\ Builds \ RavenDB-Stable \ Raven.Storage.Esent \ TransactionalStorage.cs:337行
在Raven.Database.DocumentDatabase.Query(String index,IndexQuery query)中的c:\ Builds \ RavenDB-Stable \ Raven.Database \ DocumentDatabase.cs:第781行
在Raven.Database.Server.Responders.Index.PerformQueryAgainstExistingIndex(IHttpContext context,String index,IndexQuery indexQuery,Guid&amp; indexEtag)中的c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs:第214行
位于c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs中的Raven.Database.Server.Responders.Index.ExecuteQuery(IHttpContext context,String index,Guid&amp; indexEtag):第179行
位于c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs中的Raven.Database.Server.Responders.Index.GetIndexQueryRessult(IHttpContext context,String index):第119行
位于c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs中的Raven.Database.Server.Responders.Index.OnGet(IHttpContext context,String index):第91行
位于c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ Responders \ Index.cs中的Raven.Database.Server.Responders.Index.Respond(IHttpContext context):第46行
位于c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ HttpServer.cs中的Raven.Database.Server.HttpServer.DispatchRequest(IHttpContext ctx):第550行
位于c:\ Builds \ RavenDB-Stable \ Raven.Database \ Server \ HttpServer.cs中的Raven.Database.Server.HttpServer.HandleActualRequest(IHttpContext ctx):第316行
源= Raven.Client.Lightweight
堆栈跟踪:
位于c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Connection \ HttpJsonRequest.cs中的Raven.Client.Connection.HttpJsonRequest.HandleErrors(WebException e):第422行
at 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,Boolean avoidThrowing,T&amp; result)在c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Connection \ ReplicationInformer.cs:第548行
at Raven.Client.Connection.ReplicationInformer.ExecuteWithReplication [T](String方法,String 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操作)在c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven中.Client.Lightweight \ Connection \ ServerClient.cs:第165行
在Raven.Client.Connection.ServerClient.Query(String index,IndexQuery query,String [] includes)中的c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Connection \ ServerClient.cs:第727行
在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()在c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Document \ AbstractDocumentQuery.cs:第444行
在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行
在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.执行(表达式表达式)在c:\ Builds \ RavenDB-Unstable-v1.2 \ Raven.Client.Lightweight \ Linq \ RavenQueryProvider.cs:第138行
在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来源)
at TotallyMoney.CreditCards.Admin.Web.Controllers.DailyReportController.Report(ReportPostModel reportPostModel)在C:\ Development \ Git \ MediaIngenuity \ TotallyMoney.CreditCards \ TotallyMoney.CreditCards.Admin.Web \ Controllers \ DailyReportController.cs:第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。&lt;&gt; c_ DisplayClass15.b _12()
在System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter过滤器,ActionExecutingContext preContext,Func`1 continuation)
InnerException:
答案 0 :(得分:2)
发生此异常是因为您对1.0服务器使用1.2(现在为2.0)客户端。这不受支持。
您可以将较旧的客户端与较新的服务器一起使用,但不能相反。
答案 1 :(得分:0)
如果它生成了正确的日期并且之后不需要其余的数据,您是否可以使用子字符串仅拉取日期,或者可能在方法queryable.Count()周围使用GetDate()?