I have an odd problem that has me completely stumped.
Unfortunately I have a domain object which has a lot of relationships on it (I can’t alter this) essentially when I am building up my query and just simply adding eager fetches in, after I add a certain amount, the build time increases drastically until eventually visual studio just freezes and crashes. The query is pretty simple it looks something like this:
var query = QueryOver<DomainObject>
.Fetch(x => x.Property).Eager
.Fetch(x => x.Property.PropertyA).Eager
.Fetch(x => x.Property.PropertyB).Eager
.Fetch(x => x.Property.PropertyC).Eager
.Fetch(x => x.Property.PropertyD.SubProp).Eager
.Fetch(x => x.Property.PropertyE).Eager
.Fetch(x => x.Property.PropertyF.SubProp).Eager
.Fetch(x => x.Property.PropertyG).Eager
.Fetch(x => x.Property.PropertyH.SubProp).Eager
.Fetch(x => x.Property.PropertyI).Eager
.Fetch(x => x.Property.PropertyJ).Eager
.Fetch(x => x.Property.PropertyK).Eager
.Fetch(x => x.Property.PropertyL).Eager
.Fetch(x => x.Property.PropertyM).Eager
.Fetch(x => x.Property.PropertyN).Eager
.Fetch(x => x.Property.PropertyO).Eager
.Fetch(x => x.Property.PropertyP).Eager
.Where(x => x.Id == 5);
//My fingers got tired there are in reality 33 fetches, 29 involve x.Property
query.Clone()
.Fetch(x => x.Property.PropertyN.ListProperty).Eager
.Future();
query.Clone()
.Fetch(x => x.PropertyO.ListProperty).Eager
.Future();
query.Clone()
.Fetch(x => x.PropertyD.ListProperty).Eager
.Future();
query.Clone()
.Fetch(x => x.PropertyH.ListProperty).Eager
.Future();
var results = query.Future().ToList();
That is essentially in pseudo the query we are looking at, if I comment out section of the fetches it builds fine (still slower than other projects) as I uncomment one fetch at a time the build time increases until eventually Visual Studio locks up and eventually never finishes building.
Does anyone have any clue about this at all? I have tried searching the internet but I have completely failed in finding any relevant information, at the moment lazy loading seems my only option. However I would really love an answer to this.
So, if the problem is that the compiler has a limit on the size of method chains, the solution would (theoretically) be simple: