名为“Order”的DB列与流利的NHibernate [英] DB Column named "Order" with Fluent NHibernate
本文介绍了名为“Order”的DB列与流利的NHibernate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
不幸的是,我不能改变数据库结构。
我的流利NHibernate类看起来像
public class SiteMap:AutoMap< Site>
{
public SiteMap(){
WithTable(Sites);
Id(x => x.ID,Id)
.WithUnsavedValue(0)
.GeneratedBy.Identity();
Map(x => x.Name,Name);
//各个列映射然后...
Map(x => x.SiteOrder,Order);
$ b我不知道问题是FluentNH还是NHibernate本身,但我可以确认,问题在于订单保留名称。
如何解决这个问题?
更新:建议放入[Order]的格式。谢谢!
但现在我只链接到SQL2005?
解决方案
:``订单
。由于FluentNH在运行时生成HBM文件,我想应该可以解决这个问题。
I discovered that one of the tables of a legacy db I'm working on has a colum named "Order".
Unfortunately I cannot change the DB structure.
My Fluent NHibernate class looks like
public class SiteMap : AutoMap<Site>
{
public SiteMap() {
WithTable("Sites");
Id(x => x.ID, "Id")
.WithUnsavedValue(0)
.GeneratedBy.Identity();
Map(x => x.Name, "Name");
//various columns mapping and then...
Map(x => x.SiteOrder, "Order");
}
}
I do not know if the problems is FluentNH or NHibernate itself but I can confirm that the problem lies in the "Order" reserved name.
How to solve this?
Update: as suggested putting in the form [Order] worked. Thanks!
But now I'm linked only to SQL2005?
解决方案
Try putting Order in back ticks: ``Order. Since FluentNH is generating HBM files at runtime I imagine that should fix the problem.
这篇关于名为“Order”的DB列与流利的NHibernate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文