c# - NHibernate Linq and DistinctRootEntity -


When I execute the following query, I get an exception that 'feedItemQuery' has multiple items (hence the single order default Not working).

This is expected behavior when using the Benchmark API without DistinctRootEntity transformer, but when using linq, I have a single root unit (FeedItem, with property ad (ICollection)

My query:

  var feedItemQuery = from the ad.  

in session. Link & lt; FeedItem & gt; (). ") Where ad.Id == ID select ad; Var feed istam = feed itam.singleOrDefault (); // This fails!?

Map :

  & lt; class name = "feedItem" table = "feedItems" proxy = "IFeedItem" & gt; & lt; id name = "id" type = "guid" & gt; & Lt; generator class = "guid.comb" & gt; & lt; / generator & gt; & lt; / id & gt; ... & lt; set name = "ads" table = "ads" & gt; & Lt; key column = "FeedItemId" /> 
One-to-many class = "ads" />

In advance thanks

You can use the RegisterCustomAction method to set the result transformer :

  var linqsession = session.Linq & lt; FeedItem & gt; (); Linqsession.QueryOptions.RegisterCustomAction (c => c.SetResultTransformer (New Distinction RootEntityResultTransformer ())); Var feedItemQuery = linqsession.Expand ("Advertising") from the ad where ad.Id == ID select ad  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -