Question

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

I am working with sql server 2008. By default sql server 2008 will set my primary key (Id) like clustered index but I really don't want it . I want ["IsMain"] column to be clustered index.I want to set ["IsMain"] column like clustered index s using fluent Nhibernate but I can't figure out how to do this. Thanks for your attention!

Was it helpful?

Solution

SOLUTION:

public class CustomMsSql2008Dialect : MsSql2008Dialect
        {
            public override string PrimaryKeyString
            {
                get { return "primary key nonclustered"; }
            }           

        }

Now using CustomMsSql2008Dialect like Dialect in configuration initialization I will not have primary key like clustered index , id will be nonclustered index.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top