문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top