Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are actually two questions.</p> <p><strong>Question 1: How to have a property that is loaded by some query?</strong></p> <p>Ask your self if it really needs to be in the entity. Consider to have a DTO (data transfer object) that holds data from different entities and queries instead.</p> <p>If you're sure that you need this property in the entity, take a look at <a href="http://ayende.com/Blog/archive/2009/04/07/nhibernate-mapping-ltpropertygt.aspx" rel="nofollow noreferrer">formulas</a> for single ended properties and <a href="http://ayende.com/Blog/archive/2009/05/04/nhibernate-filters.aspx" rel="nofollow noreferrer">filters</a> for collections.</p> <p>I can't provide more detailed information, because your question is highly general, and it depends on the actual problem. But you should find a solution by starting with the given links.</p> <p><strong>Question 2: How can I have a property pointing to the parent?</strong></p> <p>Very easy: By just implementing the property and map the collection of children (B) <code>"inverse=true"</code>. Implement your entities the way that they consistently point to the correct parent.</p> <p>Why is NH not doing this for you? Because NH's responsibility is only to persist your entities to the database. NH does not make any changes on the data by its own. This is responsibility of your business logic.</p> <p>Note: your application should also be able to run without NH, eg in a unit test. So relations should be managed in your code.</p>
    singulars
    1. This table or related slice is empty.
    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.
    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