3

I've recently upgraded my Linq provider to the new AST one. (NH3 on NuGet)

With the previous provider I was using linq to do "inline projections to my DTO" e.g.

from o in Session.Query<MyObject>() 
select new MyObjectDTO { 
Name = o.Name, 
SubName = o.OtherObject.Name, 
Sub2NAme = o.OtherObject2.Name 
} 

and this would generate a

SELECT o.Name, sn1.Name, sn2.Name FROM ..... 
JOIN.... JOIN....

statement.

Once I upgraded my provider I found a lot of select statements being fired off. (My projected object is more complex than above). I have come accross Fetch/FetchMany, which might help with the number of queries, but as far as I can tell it means the full object will come back for each flattened field I require.

Is there a way I can get the smallest possible number of columns required for the projection to be selected, rather than loading the full object graph to the project with?

Thanks, Chris

Chris
  • 1,241
  • 1
  • 14
  • 33

1 Answers1

1

It must be something with your usage of the result (like iterating many times the IQueryable), something odd with the mappings, or some complexity that was removed from the example.

I just tried that exact query, and only one SQL statement was generated.

Diego Mijelshon
  • 52,548
  • 16
  • 116
  • 154