Note that there are some explanatory texts on larger screens.

plurals
  1. POCan I dynamically/on the fly create a class from an interface, and will nHibernate support this practice?
    primarykey
    data
    text
    <p>I’ve done some Googling but I have yet to find a solution, or even a definitive answer to my problem.</p> <p>The problem is simple. I want to dynamically create a table per instance of a dynamically named/created object. Each table would then contain records that are specific to the object. I am aware that this is essentially an anti-pattern but these tables could theoretically become quite large so having all of the data in one table could lead to performance issues.</p> <p>A more concrete example:</p> <p>I have a base class/interface ACCOUNT which contains a collection of transactions. For each company that uses my software I create a new concrete version of the class, BOBS_SUB_SHOP_ACCOUNT or SAMS_GARAGE_ACCOUNT, etc. So the identifying value for the class is the class name, not a field within the class. </p> <p>I am using C# and Fluent nHibernate.</p> <p>So my questions are:</p> <ol> <li>Does this make sense or do I need to clarify more? (or am I trying to do something I REALLY shouldn’t?) </li> <li>Does this pattern have a name?</li> <li>Does nHibernate support this?</li> <li>Do you know of any documentation on the pattern I could read?</li> </ol> <p>Edit: I thought about this a bit more and I realized that I don't REALLY need dynamic objects. All I need is a way to tie objects with some identifier to a table through NHibernate. For example:</p> <pre><code>//begin - just a brain dump public class Account { public virtual string AccountName { get; set; } public virtual IList Stuff { get; set; } } ... somewhere else in code ... //gets mapped to a table BobsGarageAccount (or something similar) var BobsGarage = new Account{AccountName="BobsGarage"}; //gets mapped to a table StevesSubShop(or something similar) var StevesSubShop = new Account{AccountName="StevesSubShop"}; //end </code></pre> <p>That should suffice for what i need, assuming NHibernate would allow it. I am trying to avoid a situation where one giant table would have the heck beat out of it if high volume occurred on the account tables. If all accounts were in one table... it could be ugly.</p> <p>Thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload