Nhibernate search document id

256 views Asked by At

If my class derives from Entity how do I define the documentid needed for nhibernate search/lucene.net using attributes?

Is this the best way:

[DocumentId]
public virtual int Id
{
    get { return base.Id; }
    protected set { base.Id = value; }
} 

Thanks.

Christian

1

There are 1 answers

2
mathieu On

If your class derives from a base Entity, you just put the attribute on the property of the base class :

public class Entity
{
    [DocumentId]
    public int Id { get; set; }
}

You don't have to override it in derived classes.