c# - Fluent NHibernate Mapping - Saving Child object -


I have a problem with selfish NHibernate mapping, I think, mapping to avoid any problems.

I have a business object (literally, a "business"), and the review object can be several reviews in every business that are created on a page in the UI. Business review is a property, as follows:

  Public Class Business {Public Virtual Ink BusinessId {get; Set;} Public Virtual DateTime LastModified {get; Set;} Public Virtual ILIT & lt; Review & gt; Review {get; Set;} [More to be summarized further ...] Public Sector Review {Public Virtual Ink Review ID {Set; Set;} public virtual string review text {received; Set;} public virtual business business {receive; Set;} [... more for brevity has been removed ...]  

My mapping are as follows:

  Public category reviewmap: Classplop & lt; Review & gt; {Public ReviewMap () (Together ("Reviews"); ID (x => x.ReviewId). CallmanName ("Review ID") generated. Identification (); Context (x = & gt; x (Business name); map (x => x review text); [... and so on ...]} Public class businessmap: classmap  gt; { Public BusinessMap (with Affordable ("Business"); ID (x => x.BusinessId). CallName IS ("Business Id") generated. ID (); Map (x = & x; x.Name) Column name IS (" Business Name "); Map (x => X.LastModified," LastModifiedOn "); HasMany & lt; review & gt; (x = & gt; X. review). Inverted (); For lazy (); More deleted ...]}  

repository code

  using Public Zero Save (T Entity) {eSession session = GetSession () ) In the code (ITRansaction tx = session.BeginTransaction ()) {session.SaveOrUpdate (unit); tx.Commit ();}}  

In the code, I type the property to the review object Allot, and call the repository service method.

The problem is that since I am not updating the business, I hope that he will save - the review that I want is reviewed. But the code also tries to save the business, and I am getting a surprise, because I have not set the "last modified" property - nor do I want to, because I am saving the review, not the business.

How do I establish a mapping to allow it to happen?

This issue may be coming for business and review to require fireworks.

Can you include the mapping of your business object if it does not help?


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -