流利的NHibernate与保留字的列映射 [英] Fluent NHibernate Column Mapping with Reserved Word
问题描述
我读过使用反勾号应该允许使用保留字。我正在使用SQL Server和流利的NHibernate,并有一个列名文件。如果我将它映射到
$ $ p $ $ $ $ $ $
code $ pre >
尝试使用
[Fil]
所以正确添加了括号,但是从最后删除了e。如果我将它映射为
`Filee
使用
[文件]
$ c $正确的。
我做错了什么,或者这是一个NHibernate或错误Fluent Nhibernate?
解决方案
你需要把``b $ b $ $ b `File`
Astaar说,完整的语法是:
$ p $ Map(x => x.File).Column(`File` );
I've read that using a back tick ` should allow for using of reserved words. I'm using SQL Server and Fluent NHibernate and have a column name "File". If I map it with
"`File"
it tries using
[Fil]
so it's adding the brackets correctly, but dropping the "e" from the end. If I map it as
"`Filee"
it uses
[File]
correctly.
Am I doing something wrong or is this a bug in NHibernate or Fluent Nhibernate?
You need to put ` on both sides, like this:
"`File`"
As @Astaar says, the full syntax is:
Map(x => x.File).Column("`File`");
这篇关于流利的NHibernate与保留字的列映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!