带有保留字的 Fluent NHibernate 列映射 [英] Fluent NHibernate Column Mapping with Reserved Word

查看:22
本文介绍了带有保留字的 Fluent NHibernate 列映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读过使用反勾号` 应该允许使用保留字.我正在使用 SQL Server 和 Fluent NHibernate,并且有一个列名文件".如果我用

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" 

它尝试使用

[Fil]

所以它正确添加了括号,但从末尾删除了e".如果我将其映射为

so it's adding the brackets correctly, but dropping the "e" from the end. If I map it as

"`Filee"

使用

[File]

正确.

我做错了什么还是这是 NHibernate 或 Fluent Nhibernate 中的错误?

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`"

正如@Astaar 所说,完整的语法是:

As @Astaar says, the full syntax is:

Map(x => x.File).Column("`File`");

这篇关于带有保留字的 Fluent NHibernate 列映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆