Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create composite index in Fluent NHibernate?

I've seen answers for unique keys, primary keys... but nothing for a plain old composite (not unique) index definition using Fluent NHibernate.

I have:

public class ObjectPropertyMapping:ClassMap<ObjectProperty>
{
    public ObjectPropertyMapping()
    {
        Table("ObjectProperties");

        Id(x => x.ObjectPropertyID);
        References(x => x.Object);
        Map(x => x.Name);
        Map(x => x.Scale);
        Map(x => x.Precision);
        Map(x => x.Type);
        Map(x => x.Value);
    }
}

and I want to make a composite index on Object.ObjectID and Name. How do I do that?


1 Answers

I haven't tried this but I would assume you would do something like this:

public ObjectPropertyMapping()
{
    References(x => x.Object).Index("IX_OBJECT");
    Map(x => x.Name).Index("IX_OBJECT");
}
like image 138
Cole W Avatar answered Sep 16 '25 17:09

Cole W