/// <summary> /// Fluent NHibernate 에서 제공하는 Convention 설정에 따른 <see cref="IConvention"/> 인스턴스를 빌드하여 제공합니다. /// </summary> /// <param name="options">ConventionOptions 인스턴스</param> /// <returns>Convention 설정 정보를 기초로 만든 <see cref="IConvention"/>의 인스턴스 배열</returns> public static IList <IConvention> ToConventions(ConventionOptions options) { options.ShouldNotBeNull("optioons"); if (IsDebugEnabled) { log.Debug("ConventionOptions 정보로 IConvention[]을 빌드합니다... " + options); } var conventions = new List <IConvention>(); conventions.Add((options.DefaultLazy) ? LazyLoad.Always() : LazyLoad.Never()); if (options.DynamicInsert) { conventions.Add(FluentNHibernate.Conventions.Helpers.DynamicInsert.AlwaysTrue()); } if (options.DynamicUpdate) { conventions.Add(FluentNHibernate.Conventions.Helpers.DynamicUpdate.AlwaysTrue()); } if (options.TableNamePrefix.IsNotWhiteSpace()) { conventions.Add(Table.Is(x => options.TableNamePrefix + x.EntityType.Name)); } else if (options.TableNamePrefix.IsNotWhiteSpace()) { conventions.Add(Table.Is(x => x.EntityType.Name + options.TableNameSurfix)); } else { conventions.Add(Table.Is(x => x.EntityType.Name)); } if (options.PrimaryKeyName.IsNotWhiteSpace()) { conventions.Add(PrimaryKey.Name.Is(x => options.PrimaryKeyName)); } else if (options.PrimaryKeySurfix.IsNotWhiteSpace()) { conventions.Add(PrimaryKey.Name.Is(x => x.EntityType.Name + options.PrimaryKeySurfix)); } if (options.ForeignKeySurfix.IsNotWhiteSpace()) { conventions.Add(ForeignKey.EndsWith(options.ForeignKeySurfix)); conventions.Add(ConventionBuilder.HasMany.Always(x => x.Key.Column(x.EntityType.Name + options.ForeignKeySurfix))); conventions.Add(ConventionBuilder.Reference.Always(x => x.Column(x.Property.Name + options.ForeignKeySurfix))); conventions.Add(ConventionBuilder.HasManyToMany.Always(x => { x.Key.Column(x.EntityType.Name + options.PrimaryKeySurfix); x.Relationship.Column(x.ChildType.Name + options.ForeignKeySurfix); })); } return(conventions); }
protected FluentConventionBase(ConventionOptions options, IEnumerable<string> propertyWithClassNames = null, IDictionary<string, string> abbrNameMap = null) { Options = options ?? ConventionOptions.Pascal; if(propertyWithClassNames != null) _propertyWithClassNames = new List<string>(propertyWithClassNames); if(abbrNameMap != null) MappingContext.AbbrNameMap = abbrNameMap; }
protected FluentConventionBase(ConventionOptions options, IEnumerable <string> propertyWithClassNames = null, IDictionary <string, string> abbrNameMap = null) { Options = options ?? ConventionOptions.Pascal; if (propertyWithClassNames != null) { _propertyWithClassNames = new List <string>(propertyWithClassNames); } if (abbrNameMap != null) { MappingContext.AbbrNameMap = abbrNameMap; } }
/// <summary> /// Fluent NHibernate 에서 제공하는 Convention 설정에 따른 <see cref="IConvention"/> 인스턴스를 빌드하여 제공합니다. /// </summary> /// <param name="options">ConventionOptions 인스턴스</param> /// <returns>Convention 설정 정보를 기초로 만든 <see cref="IConvention"/>의 인스턴스 배열</returns> public static IList<IConvention> ToConventions(ConventionOptions options) { options.ShouldNotBeNull("optioons"); if(IsDebugEnabled) log.Debug("ConventionOptions 정보로 IConvention[]을 빌드합니다... " + options); var conventions = new List<IConvention>(); conventions.Add((options.DefaultLazy) ? LazyLoad.Always() : LazyLoad.Never()); if(options.DynamicInsert) conventions.Add(FluentNHibernate.Conventions.Helpers.DynamicInsert.AlwaysTrue()); if(options.DynamicUpdate) conventions.Add(FluentNHibernate.Conventions.Helpers.DynamicUpdate.AlwaysTrue()); if(options.TableNamePrefix.IsNotWhiteSpace()) conventions.Add(Table.Is(x => options.TableNamePrefix + x.EntityType.Name)); else if(options.TableNamePrefix.IsNotWhiteSpace()) conventions.Add(Table.Is(x => x.EntityType.Name + options.TableNameSurfix)); else conventions.Add(Table.Is(x => x.EntityType.Name)); if(options.PrimaryKeyName.IsNotWhiteSpace()) conventions.Add(PrimaryKey.Name.Is(x => options.PrimaryKeyName)); else if(options.PrimaryKeySurfix.IsNotWhiteSpace()) conventions.Add(PrimaryKey.Name.Is(x => x.EntityType.Name + options.PrimaryKeySurfix)); if(options.ForeignKeySurfix.IsNotWhiteSpace()) { conventions.Add(ForeignKey.EndsWith(options.ForeignKeySurfix)); conventions.Add(ConventionBuilder.HasMany.Always(x => x.Key.Column(x.EntityType.Name + options.ForeignKeySurfix))); conventions.Add(ConventionBuilder.Reference.Always(x => x.Column(x.Property.Name + options.ForeignKeySurfix))); conventions.Add(ConventionBuilder.HasManyToMany.Always(x => { x.Key.Column(x.EntityType.Name + options.PrimaryKeySurfix); x.Relationship.Column(x.ChildType.Name + options.ForeignKeySurfix); })); } return conventions; }