﻿<?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>Ayende Rahien commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Anatoly,
  
Wait a few days, the post about {join/} will show up
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment16</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment16</guid><pubDate>Thu, 16 Apr 2009 08:20:06 GMT</pubDate></item><item><title>tolly commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Thanks, Ayende, it works :-)
  
I have added IDictionary
&lt;string,&gt;
 Properties to my Question class to map key-value pairs. My mapping looks like this:
  
    {map name="Properties" table="QuestionDetails" }
  
      {key column="QuestionID" /}
  
      {index column="Name" type="String" /}
  
      {element column="Value" type="String" /}
  
    {/map}
  
How can i force NHibernate to use this mapping if I create new QuestionType (subclass) object? Now create a Question object as follows:
  
            Question sbq = new Question();
  
            sbq.attr1= "attr1value";
  
            sbq.attr2= "attr2value";
  
            sbq.Properties = new Dictionary
&lt;string,&gt;
();
  
            sbq.Properties.Add( "attr3", "attr3" );
  
            sbq.Properties.Add( "attr4", "attr4" );
  
And I'd like to have it so:
  
            QuestionType2 sbq = new QuestionType2 ();
  
            sbq.attr1= "attr1value";
  
            sbq.attr2= "attr2value";
  
            sbq.attr2= "attr3value";
  
            sbq.attr2= "attr4value";
  
Should I use discriminator? Or 
&lt;subclass? If I use 
&lt;subclass, than NHibernate just puts subclass attributes to the Question table, or in QuestionType2 table when using 
&lt;joined-subclass  
Thanks in advance :)
&gt;</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment15</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment15</guid><pubDate>Thu, 16 Apr 2009 08:13:42 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Tolly,
  
Take a look at {map/}
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment14</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment14</guid><pubDate>Wed, 15 Apr 2009 19:50:43 GMT</pubDate></item><item><title>tolly commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>How can i solve this (see picture) problem with NHibernate? i have a superclass Question and a lot of subclasses, all with their own specific attributes. I don't want to create table for each class, because of perfomance. The solution is to make an QuestionDetail table with key, value columns where i can store names and values of all specific attributes from subclasses. How can i do it in NHibernate?
  
[tweakers.net/.../full.jpg](http://tweakers.net/ext/f/iXzIAjRLJRji3MYD1rCoZk0J/full.jpg)</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment13</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment13</guid><pubDate>Wed, 15 Apr 2009 15:43:03 GMT</pubDate></item><item><title>CAM commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Excellent Ayende thank you.
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment12</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment12</guid><pubDate>Wed, 15 Apr 2009 13:51:43 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>CAM,
  
Take a look at the {map/} element
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment11</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment11</guid><pubDate>Wed, 15 Apr 2009 13:28:15 GMT</pubDate></item><item><title>CAM commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Sorry Ayende, I was referring to Mike's comment. Could you show an example of how to map a property bag table (Name/Value Pair) in DB to an IDictionary Attributes property of a class?
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment10</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment10</guid><pubDate>Wed, 15 Apr 2009 12:57:56 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>CAM,
  
Attributes is IDisctionary
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment9</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment9</guid><pubDate>Wed, 15 Apr 2009 11:41:31 GMT</pubDate></item><item><title>CAM commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Excellent stuff, a question on using an Attributes table comment. How would you make the Attributes property a simple dictionary?
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment8</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment8</guid><pubDate>Wed, 15 Apr 2009 11:39:50 GMT</pubDate></item><item><title>meowth commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Hrr. I had to use Boo compiler to regenerate entities on-the-fly when adding fields instead of simply using dynamic component..
  
  
Thank you for this set of lectures about NHibernate features, Ayende.
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment7</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment7</guid><pubDate>Mon, 13 Apr 2009 07:12:06 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Mike, you can create an Attributes table very easily, and map it using standard NH facilities.
  
That tend to be slower, however, because you need an additional select or a join.
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment6</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment6</guid><pubDate>Sun, 12 Apr 2009 02:58:19 GMT</pubDate></item><item><title>Mike commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Putting some data in the xml document about your mapping doesn't seem very dynamic to me. 
  
  
nor does adding a column to the database.  Is there anyway you could show an example that uses a property bag in both the database and object model?
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment5</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment5</guid><pubDate>Sun, 12 Apr 2009 02:16:14 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Justin,
  
You usually would do this by manipulating the mapping problematically.
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment4</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment4</guid><pubDate>Sat, 11 Apr 2009 18:06:18 GMT</pubDate></item><item><title>justin commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>I guess my question would be _how_ do you dynamically extend the entity?  Putting some data in the xml document about your mapping doesn't seem very dynamic to me.
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment3</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment3</guid><pubDate>Sat, 11 Apr 2009 16:40:31 GMT</pubDate></item><item><title>Ayende Rahien commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>Tobin,
  
Yes, that is what it is for. 
  
It is useful in any case where you need to dynamically extend your entities.
</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment2</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment2</guid><pubDate>Sat, 11 Apr 2009 10:45:07 GMT</pubDate></item><item><title>Tobin Harris commented on NHibernate Mapping - &lt;dynamic-component/&gt;</title><description>That's a great feature, I didn't even know it was there. 
  
  
So I guess this lets you do:
  
  
var person = _session.Load
&lt;person(1);
  
Assert.AreEqual( "123", person.Attributes["SSN"] );
  
  
I assume that mapping properties into a dictionary is the primary use case -- very handy for multi-tenanted apps -- are their any other things you've used it for?
&gt;</description><link>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment1</link><guid>http://ayende.com/3942/nhibernate-mapping-dynamic-component#comment1</guid><pubDate>Sat, 11 Apr 2009 10:39:08 GMT</pubDate></item></channel></rss>