Paul,

>From my experience, CustomSqlType is only available to PropertyPart (i.e.
the Map method) but not to IdentityPart (i.e. the Id method).

Is there some way to get this done?

Thank you.

Isaac




On Sun, Mar 7, 2010 at 1:51 PM, Paul Batum <paul.ba...@gmail.com> wrote:

> I believe something like this should do it:
>
>  Id(i => i.PersonId)
>   .CustomSqlType("MEDIUMINT")
>   .GeneratedBy.Identity();
>
>
> On Thu, Mar 4, 2010 at 8:26 PM, Isaac Inyang <isaac.iny...@gmail.com>wrote:
>
>> Hello,
>>
>> Using Fluent NHibernate, how do I specify the *Custom SQL Type* which my
>> *Identity *properties will be mapped to?
>>
>> Specifically, I want all Int32 fields to be mapped to MEDIUMINT (3 bytes)
>> within MySQL. Referring to the code below, I want PersonId to be of type
>> MEDIUMINT in the database.
>>
>> *Entity Definition*:
>>
>>     public class Person
>>     {
>>         public virtual int PersonId { get; set; }
>>         public virtual string FullName { get; set; }
>>         public virtual int Age { get; set; }
>>     }
>>
>> *Mapping Class*:
>>
>>     public class PersonMap : ClassMap<Person>
>>     {
>>         public PersonMap()
>>         {
>>             Id(i => i.PersonId).GeneratedBy.Identity();
>>             Map(i => i.FullName);
>>             Map(i => i.Age).CustomSqlType("mediumint");
>>         }
>>     }
>>
>> *Generated HBM File*:
>>
>> <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"
>> name="netquepgcurrent.Entities.Person, netquepgcurrent, Version=1.0.0.0,
>> Culture=neutral, PublicKeyToken=null" table="`Person`">
>>     <id name="PersonId" type="System.Int32, mscorlib, Version=2.0.0.0,
>> Culture=neutral, PublicKeyToken=b77a5c561934e089">
>>       <column name="PersonId" />
>>       <generator class="identity" />
>>     </id>
>>     <property name="FullName" type="System.String, mscorlib,
>> Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
>>       <column name="FullName" />
>>     </property>
>>     <property name="Age" type="System.Int32, mscorlib, Version=2.0.0.0,
>> Culture=neutral, PublicKeyToken=b77a5c561934e089">
>>       <column name="Age" sql-type="mediumint" />
>>     </property>
>>   </class>
>> </hibernate-mapping>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Fluent NHibernate" group.
>> To post to this group, send email to fluent-nhibern...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/fluent-nhibernate?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Fluent NHibernate" group.
> To post to this group, send email to fluent-nhibern...@googlegroups.com.
> To unsubscribe from this group, send email to
> fluent-nhibernate+unsubscr...@googlegroups.com<fluent-nhibernate%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/fluent-nhibernate?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@googlegroups.com.
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en.

Reply via email to