Reputation: 431
i am using NHibernate together with a Firebird Database and are not sure if the String-Types are mapped correctly. In .NET a String-Type is normally UTF16 encoded. In Firebird i have defined my Domain wie Character Set UTF8.
So if i have this Domain-Class:
public class Project
{
public virtual Int64 ID { get; set; }
public virtual String Name { get; set; }
}
and this NHibernate Mapping:
<class name="Project">
<id name="Id">
<generator class="sequence">
<param name="sequence">MY_GEN</param>
</generator>
</id>
<property name="Name"/>
</class>
Does NHibernate automatically converts my System.String to a Firebird UTF8 String in this case? It seems to be ok in the database. But i am not sure about the handling in NHibernate.
Upvotes: 2
Views: 1519
Reputation: 5679
The default string type for NHibernate saves the data using DbType.String (which is a Unicode string). Firebird will encode the unicode string in UTF8 for you.
The alternative (without getting into custom types) would be to specify an AnsiString type which would also work with UTF8 if all you used was ASCII characters.
Since you're not specifying the type, NHibernate will use it's StringType and it will work properly.
Upvotes: 1