NHibernate - Force escaping on Table Names

别来无恙 提交于 2019-12-07 03:05:40

问题


Are there any good examples of how to use this (NHibernate.Criterion.IdentifierEqExpression) online? I couldn't find any. I'm a little confused about what you are supposed to pass into the constructor.

I pass in an int32 of 1 and I keep thinking my test should basically do a "where id = 1" type of query and instead it blows up with "where id = ?" and something about positional parameters. If that's not what is supposed to be passed into the constructor ... what is?

Real Issue
When I look at SQL output it seems to be working correctly except for the fact my table is named User and NHibernate isn't enclosing it like [User]. Any way to force this?


回答1:


Specify the table name as `User`. For example:

(HBM)
<class name="User" table="`User`">

(Fluent)
public UserMap()
{
    WithTable("`User`");
    ...

(Mapping By Code)
public UserMap()
{
    Table("`User`");
    ...

Similarly, with columns you'll have to do something like:

Map(x => x.IsCurrent, "`Current`");

Oh the joys of working with legacy DBs.



来源:https://stackoverflow.com/questions/679279/nhibernate-force-escaping-on-table-names

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