2

I'm discovering nhibernate right now. Thus my question is maybe very stupid :)

What I'm trying to do (I'm working with a legacy database) is to get an entity which some of its data are coming from a table value function. My entity is the following

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

where AccessRightId comes from the table value function (fp_AccessRight('userId'))

I have the following mapping

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();
            });
    }        
}

Unfortunately, I'm not able to substitute 'userId' by any value. Thanks. Is there a way to do it?

1
  • you could post it as answer and accept it so others find it more easily Commented Sep 5, 2012 at 12:04

1 Answer 1

1

I finally solved it.

The trick was to make the join like this :

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

and then simpley to enable the filter

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

I found an example here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.