public class BaseObject
{
public string Id { get; set; }
}
public class Property : BaseObject
{
public string Name { get; set; }
public string CityId { get; set; }
}
public class School : BaseObject
{
public string Name { get; set; }
public string CityId { get; set; }
}
public class City : BaseObject
{
public string Name { get; set; }
public string RegionId { get; set; }
public string CountryId { get; set; }
}
public class Region : BaseObject
{
public string Name { get; set; }
public string CountryId { get; set; }
}
public class Country : BaseObject
{
public string Name { get; set; }
}
public class MultiMapIndex : AbstractMultiMapIndexCreationTask<BaseObject>
{
public MultiMapIndex()
{
AddMap<School>(schools => from school in schools
let city = LoadDocument<City>(school.CityId)
select new
{
Id = school.Id,
Name = school.Name,
CityId = city.Id,
RegionId = city.RegionId,
CountryId = city.CountryId
});
AddMap<Property>(properties => from property in properties
let city = LoadDocument<City>(property.CityId)
select new
{
Id = property.Id,
Name = property.Name,
CityId = city.Id,
RegionId = city.RegionId,
CountryId = city.CountryId
});
Store("RegionId", FieldStorage.Yes);
}
using (var session = store.OpenSession())
{
var result = session.Query<BaseObject, MultiMapIndex>()
.Customize(customization => customization.WaitForNonStaleResultsAsOfNow())
.Include(x => ((School)x).CityId)
.Customize(x =>
{
var luceneQuery = (IDocumentQuery<BaseObject>)x;
luceneQuery.Include("RegionId");
})
.ToList();
Assert.That(result[0].Id == _school.Id);
Assert.That(result[1].Id == _property.Id);
Assert.That(session.Advanced.NumberOfRequests == 1); // Just to make sure
var city = session.Load<City>(_school.CityId);
Assert.That(session.Advanced.NumberOfRequests == 1); // Should of remained 1. <------- This passes
var region = session.Load<Region>(city.RegionId);
Assert.That(session.Advanced.NumberOfRequests == 1); // Should of remained 1. <-------- This fails
}
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.