I am using sharp architecture, and learning it. My question is How
does property Id map to an existing table primary key field with non
conventional name such as my_isn?
I have a entity class Vendor is like this:
public class Vendor : Entity
{
public Vendor() { }
public Vendor(string vendor_name) {
Vendor_Name = vendor_name;
}
public virtual int Id { get; protected set; }
[DomainSignature]
[NotNullNotEmpty]
public virtual string Vendor_Name { get; protected set; }
}
my mapping class is like:
class VendorMap : IAutoMappingOverride<Vendor>
{
public void Override(AutoMapping<Vendor> mapping)
{
mapping.Table("my_tbl_deal_vendor");
mapping.Id(x => x.Id,
"My_Vendor_ISN").GeneratedBy.Native().Column("My_Vendor_ISN"); // not
working
//mapping.Id(x => x.Id,
"My_Vendor_ISN").GeneratedBy.Identity(); // not working
// mapping.Id(x =>
x.Id).GeneratedBy.HiLo("1000").Column("My_Vendor_ISN").Not.Nullable(); //
not working
mapping.Map(x => x.Vendor_Name).Column("My_Vendor_Name");
//also tried: mapping.Map(x => x.Vendor_Name, "My_Vendor_Name");
}
it generates hbm file as :
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-
access="property" auto-import="true" default-cascade="none" default-
lazy="true">
<class xmlns="urn:nhibernate-mapping-2.2" mutable="true"
name="myDeals.Core.Vendor, myDeals.Core, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null" table="a2z_tbl_deal_Vendor">
<id name="Id" type="System.Int32, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Id" />
<generator class="identity" />
</id>
<property name="Vendor_Name" type="System.String, mscorlib,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<column name="Vendor_Name" />
</property>
</class>
</hibernate-mapping>
Id property is not able to map my existing table primary key
field My_Vendor_ISN, and Vendor_Name cannot map to My_Vendor_Name.
What can I do to map property to existing table column name?
Why does this happen?
--
You received this message because you are subscribed to the Google Groups
"Fluent NHibernate" 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/fluent-nhibernate?hl=en.