Set column collate in NHibernate mapping

荒凉一梦 提交于 2019-12-13 02:23:24

问题


I'm looking into NHibernate mapping and we are in a situation where we require to specify the collate on a specific column. Preferably during the mapping.

The idea is that after NHibernate creates the schema, it will look something like this:

CREATE TABLE [dbo].[Foo] (
    [Bar]        NVARCHAR (128) NULL **collate sql_latin1_general_cp1_cs_as**,
    [BarTwo]     NVARCHAR (max)
);

I'm currently using Fluent but an xml solution would be fine as well.


回答1:


I found out that I can add the collate to the CustomSqlType. It does mean that I need to add always a CustomSqlType and therefore make the mapping database depended.

.CustomSqlType("nvarchar(128) collate Latin1_General_CI_AS")

But for now it seems to work. Anyone has another/better idea/proposition?



来源:https://stackoverflow.com/questions/15385738/set-column-collate-in-nhibernate-mapping

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!