【问题标题】:nhibernate join table value functionnhibernate连接表值函数
【发布时间】:2012-09-05 07:48:00
【问题描述】:

我现在正在发现 nhibernate。因此我的问题可能很愚蠢:)

我正在尝试做的(我正在使用旧数据库)是获取一个实体,该实体的一些数据来自表值函数。 我的实体如下

public class Entity
{
  public virtual int Id { get; protected set; }
  ....
  public virtual int AccessRightId { get; set; }
}

其中AccessRightId来自表值函数(fp_AccessRight('userId'))

我有以下映射

public class EntityMap : ClassMap<Entity>
  {
    public EntityMap ()
    {
      this.Id(entity => entity .Id);          
      this.Join(
          "fp_AccessRight('userId')",
            join =>
            {
                join.Fetch.Join();
                join.KeyColumn("EntityId");
                join.Map(t => t.AccessRightId, "AccessRightType");
                join.Table();
            });
    }        
}

很遗憾,我无法将“userId”替换为任何值。 谢谢。 有什么办法吗?

【问题讨论】:

  • 您可以将其发布为答案并接受它,以便其他人更容易找到它

标签: nhibernate nhibernate-mapping fluent-nhibernate-mapping


【解决方案1】:

我终于解决了。

诀窍是像这样进行连接:

this.Join("fp_ACCOUNT_ACL(:AclFilter.userId)"

然后简单地启用过滤器

this.session.EnableFilter("AclFilter").SetParameter("userId", "bdd#5");  

我找到了一个例子here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-23
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多