I think I have the most simple index possible:
public class ZipCodesWithAgent : AbstractIndexCreationTask<ZipCode, ZipCodesWithAgent.Result>
{
public class Result
{
public ZipCode ZipCode { get; set; }
public Agent Agent { get; set; }
}
public ZipCodesWithAgent()
{
Map = zipcodes => from zip in zipcodes
select new
{
ZipCode = zip,
Agent = LoadDocument<Agent>(zip.AgentId)
};
Store(x => x.Agent, Raven.Abstractions.Indexing.FieldStorage.Yes);
Store(x => x.ZipCode, Raven.Abstractions.Indexing.FieldStorage.Yes);
}
}
I have tried each of the following:
var data = RavenSession.Query<ZipCodesWithAgent.Result, ZipCodesWithAgent>();
var data = RavenSession.Query<ZipCodesWithAgent.Result, ZipCodesWithAgent>().OfType<ZipCodesWithAgent.Result>();
But get:
Unable to cast object of type 'Models.ZipCode' to type 'Result'.
Every time. Any help is appreciated.