I have an index that looks like
public class FeedAnnouncementByOneLabel : Raven.Client.Indexes.AbstractIndexCreationTask<FeedPost, FeedAnnouncementByOneLabel.Result>
{
public class Result
{
public long SequentialId { get; set; }
public string AnnouncementId { get; set; }
public string Label1 { get; set; }
public string FeedOwner { get; set; }
public DateTimeOffset CreationDate { get; set; }
}
public FeedAnnouncementByOneLabel()
{
Map = announcements => from doc in announcements
from docLabelsItem1 in ((IEnumerable<Label>)doc.Labels).DefaultIfEmpty()
select new Result
{
SequentialId = doc.SequentialId,
AnnouncementId = doc.AnnouncementId,
CreationDate = doc.CreationDate,
FeedOwner = doc.FeedOwner,
Label1 = docLabelsItem1.Text
};
}
}
And I request it like this (simplified version that STILL doesn't work with):
from c in _session.Query<FeedAnnouncementByOneLabel.Result, FeedAnnouncementByOneLabel>()
select c;
I get an exception EVERY TIME I request it. The strangest thing is that it worked. I'm not sure I broke it since I upgraded Raven to the latest version - or because of something else, I changed. I am sure that the only thing that has changed is that I moved "FeedPost" to my own DLL (with various DataContract attributes on it).
Any members?
thank
<Exception xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ExceptionType>System.InvalidCastException</ExceptionType>
<Message>
Unable to cast object of type 'FeedPost' to type 'Result'.
</Message>
<StackTrace>
at Raven.Client.Document.InMemoryDocumentSessionOperations.ConvertToEntity[T](String id, RavenJObject documentFound, RavenJObject metadata) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 416
at Raven.Client.Document.InMemoryDocumentSessionOperations.TrackEntity[T](String key, RavenJObject document, RavenJObject metadata) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:line 340
at Raven.Client.Document.SessionOperations.QueryOperation.Deserialize[T](RavenJObject result) in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:line 130
at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at Raven.Client.Document.SessionOperations.QueryOperation.Complete[T]() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\SessionOperations\QueryOperation.cs:line 114
at Raven.Client.Document.AbstractDocumentQuery`2.GetEnumerator() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Document\AbstractDocumentQuery.cs:line 603
at Raven.Client.Linq.RavenQueryInspector`1.GetEnumerator() in c:\Builds\RavenDB-Stable\Raven.Client.Lightweight\Linq\RavenQueryInspector.cs:line 98
at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
at FeedPostsController.Get(String labels, Int32 sincePostId) in FeedPostsController.cs:line 211
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.Execute(HttpControllerContext controllerContext, IDictionary`2 arguments)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<>c__DisplayClass2.<InvokeActionAsync>b__0()
at System.Threading.Tasks.TaskHelpers.RunSynchronously[TResult](Func`1 func, CancellationToken cancellationToken)
</StackTrace>
</Exception>
[UPDATE]
Good - I moved the FeedPost definition back to the same DLL that had the indexes ... still failed.
source
share