0

Suppose I have following table:

 public class ResourcePossibleUm : EntityBase
    {
        public virtual bool IsMain { get; set; }
        public virtual double UmMass { get; set; }
        -------
    }

And mapping:

public class ResourcePosibleUMMap : ClassMap<ResourcePossibleUm>
    {
        public ResourcePosibleUMMap()
        {
            Id(x => x.Id).GeneratedBy.Identity();           
            Map(x => x.IsMain);
            Map(c => c.UmMass);
        }
    }

Id is primary key if ResourcePossibleUM table , and non clustered index for this table.Now I want to set clustered index column ["IsMain"] and I really can't find how to do this. Any help will be depreciated .Thanks a lot!

Nic
  • 1,088
  • 3
  • 19
  • 43
  • I believe the answer can be found here: http://stackoverflow.com/questions/1356467/how-can-you-create-clustered-indexes-with-fluent-nhibernate – Cole W Apr 16 '14 at 00:39
  • I saw this answer but I can't figure out how to do this in fluent mapping, or how to mix fluent mapping with traditional Nhibernate mapping... – Nic Apr 16 '14 at 07:36

1 Answers1

0

You cannot do a CLUSTERED index with Fluent. You can do a "compound" Index....(non clustered)....

Generic example below: (The key being to use the same name... twice. "IX_Employee_EmployeeUUID_And_SSN" in the example below)

public class EmployeeMap : ClassMap<EmployeeNHEntity>
{
    public EmployeeMap()
    {

        Schema("dbo");
        Table("Employee");

        Id(x => x.EmployeeUUID).GeneratedBy.GuidComb().Index("IX_Employee_EmployeeUUID_And_SSN");

        Map(x => x.SSN).Index("IX_Employee_EmployeeUUID_And_SSN");
        Map(x => x.LastName);
        Map(x => x.FirstName);
granadaCoder
  • 26,328
  • 10
  • 113
  • 146