在NHibernate映射中设置列整理 [英] Set column collate in NHibernate mapping
问题描述
我正在研究NHibernate映射,因此我们需要在特定列上指定排序规则.最好在映射过程中.
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.
这个想法是,NHibernate创建架构后,它将看起来像这样:
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)
);
我目前正在使用Fluent,但也可以使用xml解决方案.
I'm currently using Fluent but an xml solution would be fine as well.
推荐答案
我发现可以将排序规则添加到CustomSqlType. 这确实意味着我需要始终添加一个CustomSqlType,从而使映射数据库依赖.
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?
这篇关于在NHibernate映射中设置列整理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!