c# - Handling a one-to-many relationship with value types in Fluent NHibernate -
I am working on migrating an application to NHibernate, and I am using Fluent NIBnet
I have a In the database (SQL 2008), these values are kept in different tables. That's why I can have The problem is that I would not like to use a simple Update: A little more info It seems that the SQL is not being generated properly. I try to look at the list of customer's phone numbers, I get an ado error that says that NHBernate is looking for a table called PhoneNumber. It seems that it is up Is not the default You can map to multiple tables in the same object PhoneNumber using the entity-name mapping feature. Sorry, there is no sample code - I do not use the brain, so I can not help with that aspect. I can post sample HBM mapping if it would be helpful unit name basically The name of the class name across the board. When you use unit-name, you must modify your session to accept a parameter to specify the entity name to work with the object through the session. The documentation is here: Edit HDMI samples. This map is an object phone number for multiple tables Then to call an example on Phononumber, you modify the session syntax in the following, so nhibernate knows what to use the table: You have to find out that Fluent also supports it, if so, if so, you can always Can use HBM files for PhoneNumber object. phone number value type in which there are some properties -
number ,
number type , and
details < / Code>. There are several objects in my domain that have a phone number store.
customer and
customer phone number as well as
vendors and
seller phone number .
PhoneNumber value type without having
customer phone number and
seller phone number Type whose properties are related to their parent's type, and I do not know how to accomplish it in NHibernate Is it possible or do I need to match my domain object more closely to the built-in database schema? is?
It seems that I'm having trouble getting a basic map to work for the encounter. Here's a simple example:
Public class CustomerMap: ClassMap & lt; Customers & gt; {Public clientmap} (table ("customer"); id (x = & gt; x.Id); map (x = & gt; x.Name); element (x = & gt; x address); HasMany ( X = & gt; x.PhoneNumbers). Calculate ("Customer ID") .Cascade.All (). ("Customer Phone Phone")}}} Public Category Phonemap: Classmap
table ("consumerphonephone") is the default on a table called the same thing as part and object, yet I can not specify a table in the PhoneNumberMap, depending on which route the root For we are pulling, its coming Will be different on the edge.
& lt; Hibernate-mapping xmlns = "kalash: nishbenet -mapping-2.2" & gt; & Lt; Class name = "DomainModel.PhoneNumber, DomainModel" table = "PhoneNumberVendors" entity-name = "phone number vendor" & gt; & Lt; Id name = "_ id" access = "field" column = "phone number" & gt; & Lt; Generator class = "assigned" /> & Lt; / Id & gt; & Lt; Property Name = "..." & gt; & Lt; / Square & gt; & Lt; Class name = "DomainModel.PhoneNumber, DomainModel" table = "PhoneNumberCustomers" entity-name = "PhoneNumberCustomer" & gt; & Lt; Id name = "_ id" access = "field" column = "phone number" & gt; & Lt; Generator class = "assigned" /> & Lt; / Id & gt; & Lt; Property Name = "..." & gt; & Lt; / Square & gt; & Lt; / Hibernate-mapping & gt;
_session.Update ("PhoneNumberCustomer", myCustomerNumber)
Comments
Post a Comment