Search code examples
c#nhibernatealiascriterianhibernate-envers

Envers NHibernate - Create alias in query


Is there a way to create an alias with Envers NHibernate similar to the ones we can do with old school NHibernate expression?

I would like to be able to do something like:

reader.Add(AuditEntity.Property("Dog.Name").Eq("Fido"));

Where the classic NHibernate expressions would look like:

session.CreateCriteria(typeof(DogOwner))
    .CreateAlias("Dog", "Dog")
    .Add(Expression.EqProperty("Dog.Name", "Fido") )

Solution

  • You can't today.

    From the docs

    "The main limitation of the current queries implementation is that you cannot traverse relations. You can only specify constraints on the ids of the related entities, and only on the "owning" side of the relation. This however will be changed in future releases."

    You need to do the join "manually" using multipe queries.