This is not related to NH it is about design of you 'entities'.

My solution to your issue to do it like following:

1. Do not persist IsBlocked property: make it looks like:
public virtual bool IsBlocked { get { return BlockDate != null; } }

2. Add method Block to user, which set BlockDate:

public virtual void Block () { BlockDate = DateTime.Now; }

3. Profit.

2012/5/30 rfDelanhese <[email protected]>

>
> Hello, I´m trying to get started in the “DDD with C#” world.
> I use NHibernate as my ORM tool, thus trying to develop a
> PI(Persistence Ignorance) model.
> However, in some of my entities (which are being represented as POCOS)
> I have  business rules in the setters of my properties.
> For example, I have a “User” entity which have a flag that indicates
> if this user is blocked or not, when this flag is true a second field
> called “Block Date”
>  must be automatically filled whith the current date.
> Everything seems very clear and simple, but the problem arises in the
> moment that I´m recovering users that has already persisted in the
> database, even though
> the blocked users will have their “Blocked Dates” update to the
> current date, according whit this logic.
> Initially I thought in a second flag “isLoaded” that would indicates
> that the object is being hydrated by NHibernate and then this logic
> wouldn´t be launched,
>  however this didn´t seem like PI. Any suggestion on how to improve
> this?
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to