Sorry for the wall of text please don't TLDR. I have a very simple object model, basically it's
public class Colony
{
public virtual IList<Ant> Ants { get; set; }
}
public class Ant
{
public bool Dead { get; set }
public virtual IList<Egg> Eggs { get; set; }
}
public class Egg
{
public bool Dead { get; set }
public virtual int IncubationPeriod { get; set; }
}
You get the idea. So I have declared two mapping overrides.
public class ColonyMappingOverride : IAutoMappingOverride<Colony>
{
public void Override(AutoMapping<Colony> mapping)
{
mapping.HasMany(c => c.Ants).Where(x => !x.Dead);
}
}
public class AntMappingOverride : IAutoMappingOverride<Ant>
{
public void Override(AutoMapping<Ant> mapping)
{
mapping.HasMany(c => c.Eggs).Where(x => !x.Dead);
}
}
So when I grab data out of the DB I end up with inconsistent data.
For example:
Colony.Ants doesn't contain any dead ants (as expected), however Colony.Ants[0].Eggs contains all Eggs... dead or not.
If I call a Session.Refresh(Colony.Ants[0]) the dead eggs get removed.
Anyone know why lazy loading is ignoring the Where clause on the Ants mapping override?