﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Fabio Maulo commented on Partial Object Queries With NHibernate</title><description>A year ago i made something similar in a prj.
  
  
I port it to uNhAddIns naming it PositionalToBeanResultTransformer.
  
  
Apparently is not a best practices but, if more than one developer need it, it is useful.
  
  
 ;)
  
  
Bye.
  
Fabio.
</description><link>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment7</link><guid>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment7</guid><pubDate>Tue, 18 Sep 2007 23:40:16 GMT</pubDate></item><item><title>freeblog commented on Partial Object Queries With NHibernate</title><description>Register your own WordPress blog here!
</description><link>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment6</link><guid>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment6</guid><pubDate>Wed, 29 Aug 2007 08:29:48 GMT</pubDate></item><item><title>jmajaranta commented on Partial Object Queries With NHibernate</title><description>Thank you for your time Ayende. 
  
Yeah, the transformer was simple to build, except for the collections.
  
Now the transformer works by transforming tuples first to a hiearchy 
  
where the DTO's collections contain only one item, and then consolidates
  
the collections in the TransformList method to a distinct root DTO which has to provide some business ID to group the collections. A dirty solution was to use GetHashCode() for now...
  
  
I didn't read your code careful enough to realize you were using the transformer with HQL queries.
  
Nice ;) I was under the impression the transformers wouldn't work
  
with HQL queries (although supported) because I couldn't get the built-in transformers to work (mainly the AliasToBeanResultTransformer). Now I know why I ;)
  
  
  
</description><link>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment5</link><guid>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment5</guid><pubDate>Tue, 28 Aug 2007 04:05:26 GMT</pubDate></item><item><title>Ben Scheirman commented on Partial Object Queries With NHibernate</title><description>While the code is cool, I agree with you on the point that this leads to fuzzy-looking objects.
  
  
Picture for example you have an .Equals() implementation that checks those 2 properties + the author's name.  The author's name isn't loaded so it needs to trigger a refresh.
  
  
So now if we use a semi-harmless method like .Contains() we will likely have introduced one of the leakiest abstractions that we could possibly accomplish.  Picture this...
  
  
if(blogs.Contains(partialBlogInstance))
  
{
  
  //do something
  
}
  
  
This code will now either have the strange side effect of going to the database --or -- throwing an exception because we've lost session at this point.
  
  
I can't see why someone would really want to do this.  Write a DTO for things like dropdowns and pull those out of your tuple arrays.
</description><link>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment4</link><guid>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment4</guid><pubDate>Mon, 27 Aug 2007 18:19:19 GMT</pubDate></item><item><title>Ayende Rahien commented on Partial Object Queries With NHibernate</title><description>The AliasToBeanResultTransformer is built to be used with a criteria.
  
I would suggest building a customer result transformer for that, it is very simple,and you can have it do it your way
</description><link>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment3</link><guid>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment3</guid><pubDate>Mon, 27 Aug 2007 16:40:22 GMT</pubDate></item><item><title>Colin Jack commented on Partial Object Queries With NHibernate</title><description>Interesting to know that its possible but as you say its probably something you want to avoid.
</description><link>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment2</link><guid>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment2</guid><pubDate>Mon, 27 Aug 2007 08:34:03 GMT</pubDate></item><item><title>jmajaranta commented on Partial Object Queries With NHibernate</title><description>Wouldn't the AliasToBeanResultTransformer do exactly the same thing?
  
  
I was trying to get NHibernate's projections to return hierarchial
  
DTO's, that is a DTO child objects and setting the child object's properties, and also collections, so you could get NHibernate to fill something like MyDTO.MyChildDTO.Name and MyDTO.DTOChildren[0].Name (and of course MyDTO.MyChildDTO.MyChildDTO2.Name and MyDTO.DTOChildren[0].MyChildDTO.Name).
  
  
I couldn't find any other way to do this than writing a custom IResultTransformer.
  
  
Do you know if NHibernate
  
would support this out-of-the-box or is a custom IResultTransformer the way to go ?
  
  
</description><link>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment1</link><guid>http://ayende.com/2741/partial-object-queries-with-nhibernate#comment1</guid><pubDate>Mon, 27 Aug 2007 05:57:26 GMT</pubDate></item></channel></rss>