I linq to sql I could make a partial view and do something like this
public partial class User
    {
        partial void OnNameChanged()
        {
            UserName = StringFormatter.ToTitleCase(UserName.Trim());
        }
        partial void OnEmailChanged()
        {
            Email = Email.ToLower().Trim();
        }
    }
can I do something like this in nhibe开发者_运维知识库rnate. Also if you can. Can you do something like that OnQuery or OnSave?
The best way to do that with NHibernate would be to use the property accessors directly:
public class User
{
   ...
   private string userName;
   public virtual string UserName
   {
       get{return StringFormatter.ToTitleCase(userName.Trim());}
       set{userName = StringFormatter.ToTitleCase(value.Trim());}
   }
   private string email
   public virtual string Email
   {
       get{return email.Trim().ToLower();}
       set{email= value.Trim().ToLower();}
   }
   ...
}
Since NHibernate doesn't generate the DAO, but instead just uses your existing domain object, you have complete control over get/set logic. No need for a partial (though you could set it up that way to, if you really wanted).
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论