<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-36201586.post3652972974965105385..comments</id><updated>2009-04-05T22:36:03.231+01:00</updated><title type='text'>Comments on Derek says:: Implicit polymorphism and lazy collections in NHib...</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://derek-says.blogspot.com/feeds/3652972974965105385/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html'/><author><name>Derek Fowler</name><uri>http://www.blogger.com/profile/09963865123124577525</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>8</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-36201586.post-6620887381642957596</id><published>2009-04-05T22:36:00.000+01:00</published><updated>2009-04-05T22:36:00.000+01:00</updated><title type='text'>I'm not sure that will work as you're still trying...</title><content type='html'>I&amp;#39;m not sure that will work as you&amp;#39;re still trying to cast the object to a type it isn&amp;#39;t derived from. Also even if you did use this method you&amp;#39;d end up needing lots of calls to GetAsType&amp;lt;&amp;gt;() and if(){} statements to check the cast was successful, the resulting code wouldn&amp;#39;t be as elegant.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/6620887381642957596'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/6620887381642957596'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1238967360000#c6620887381642957596' title=''/><author><name>Derek Fowler</name><uri>http://www.blogger.com/profile/09963865123124577525</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='01005108689222898985'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-36201586.post-2411860805602674970</id><published>2009-04-05T21:06:00.000+01:00</published><updated>2009-04-05T21:06:00.000+01:00</updated><title type='text'>I think the easiest way is to add a method to the ...</title><content type='html'>I think the easiest way is to add a method to the base class: &lt;BR/&gt;&lt;BR/&gt;public virtual T GetAsType&amp;lt;T&amp;gt;() where T :class&lt;BR/&gt;        {&lt;BR/&gt;            return this as T;&lt;BR/&gt;        }</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/2411860805602674970'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/2411860805602674970'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1238961960000#c2411860805602674970' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-36201586.post-3272793992712752795</id><published>2009-02-13T02:48:00.000Z</published><updated>2009-02-13T02:48:00.000Z</updated><title type='text'>Me too, I cannot see the source code of NH-1090 ;(...</title><content type='html'>Me too, I cannot see the source code of NH-1090 ;( No, the transform is being applied after the caching occurs. That's why I wonder What's the real problem? &lt;BR/&gt;&lt;BR/&gt;You could see the code of Loader.ListUsingQueryCache method, and StandardQueryCache.Put method.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/3272793992712752795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/3272793992712752795'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1234493280000#c3272793992712752795' title=''/><author><name>sakumira</name><uri>http://www.blogger.com/profile/05355093424292701137</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-36201586.post-6976640225155465981</id><published>2009-02-12T22:39:00.000Z</published><updated>2009-02-12T22:39:00.000Z</updated><title type='text'>I think this is down to issue NH-1090 but http://j...</title><content type='html'>I think this is down to issue NH-1090 but http://jira.nhibernate.org/ is timing out at the moment so I can't check.&lt;BR/&gt;&lt;BR/&gt;If I remember rightly the transform is being applied before the caching occurs so NHibernate expects something like an object[] but ends up with something else.&lt;BR/&gt;&lt;BR/&gt;I don't think there is a work around for this - we ended up having to hack the source of NHibernate. I can't remember whether it was straightforward or not.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/6976640225155465981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/6976640225155465981'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1234478340000#c6976640225155465981' title=''/><author><name>Derek Fowler</name><uri>http://www.blogger.com/profile/09963865123124577525</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='01005108689222898985'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-36201586.post-6796663773106464545</id><published>2009-02-12T02:49:00.000Z</published><updated>2009-02-12T02:49:00.000Z</updated><title type='text'>I have checked, the call to a method (other than G...</title><content type='html'>I have checked, the call to a method (other than GetType, GetHashCode methods) of a proxy will trigger lazy-load the object fully, and call the method of real object. Therefore, thank you for your solution.&lt;BR/&gt;&lt;BR/&gt;Now, I am facing another big problem with polymorphism in NHibernate. The polymorphic query does not work with any ResultTransformer when Query Cache is enable :( Do you  have any idea?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/6796663773106464545'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/6796663773106464545'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1234406940000#c6796663773106464545' title=''/><author><name>sakumira</name><uri>http://www.blogger.com/profile/05355093424292701137</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-36201586.post-5768318565144911871</id><published>2009-02-05T21:50:00.000Z</published><updated>2009-02-05T21:50:00.000Z</updated><title type='text'>The items of the collection are proxies, that is t...</title><content type='html'>The items of the collection are proxies, that is the nature of the problem. The proxy is a subclass of the class specified as the collection item, in this case Mammal. When the object is hydrated from the database you end up with the correct type however it is still "boxed" as a Mammal so you can't test the type to see what it is you have.&lt;BR/&gt;&lt;BR/&gt;Visitor works because the object itself knows what type it is so when you pass in your visitor to the object the object calls the correct overloaded method on your visitor.&lt;BR/&gt;&lt;BR/&gt;The solution is the same for a lazy one-to-many property.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/5768318565144911871'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/5768318565144911871'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1233870600000#c5768318565144911871' title=''/><author><name>Derek Fowler</name><uri>http://www.blogger.com/profile/09963865123124577525</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='01005108689222898985'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-36201586.post-2083619155984457515</id><published>2009-02-05T04:53:00.000Z</published><updated>2009-02-05T04:53:00.000Z</updated><title type='text'>I don't think your visitor can work if Mammal is a...</title><content type='html'>I don't think your visitor can work if Mammal is a proxy.&lt;BR/&gt;&lt;BR/&gt;For polymorphic one-to-many lazy property, it works as well in NHibernate. There is just a problem on polymorphic many-to-one lazy property (proxy). I am looking for a solution on this case too.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/2083619155984457515'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/2083619155984457515'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1233809580000#c2083619155984457515' title=''/><author><name>sakumira</name><uri>http://www.blogger.com/profile/05355093424292701137</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-36201586.post-4555142732898206886</id><published>2009-02-05T04:33:00.000Z</published><updated>2009-02-05T04:33:00.000Z</updated><title type='text'>I don't think so, when the lazy collection is load...</title><content type='html'>I don't think so, when the lazy collection is loaded, items will be fetched with correct type according to discriminator value. Unless, a Mammal instance is a proxy (session.Load), but in that case, your visitor will not be able to know about the type of proxy class.&lt;BR/&gt;&lt;BR/&gt;There is just a problem when using polymorphism on lazy property (many-to-one). I am looking for a solution for this case :(</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/4555142732898206886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/36201586/3652972974965105385/comments/default/4555142732898206886'/><link rel='alternate' type='text/html' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html?showComment=1233808380000#c4555142732898206886' title=''/><author><name>sakumira</name><uri>http://www.blogger.com/profile/05355093424292701137</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://derek-says.blogspot.com/2008/05/implicit-polymorphism-and-lazy.html' ref='tag:blogger.com,1999:blog-36201586.post-3652972974965105385' source='http://www.blogger.com/feeds/36201586/posts/default/3652972974965105385' type='text/html'/></entry></feed>