public void Apply(IManyToManyCollectionInstance instance) { if (instance.OtherSide == null) { // uni-directional var tableName = GetUniDirectionalTableName(instance); instance.Table(tableName); } else { // bi-directional if (instance.HasExplicitTable && instance.OtherSide.HasExplicitTable) { // TODO: We could check if they're the same here and warn the user if they're not return; } if (instance.HasExplicitTable && !instance.OtherSide.HasExplicitTable) instance.OtherSide.Table(instance.TableName); else if (!instance.HasExplicitTable && instance.OtherSide.HasExplicitTable) instance.Table(instance.OtherSide.TableName); else { var tableName = GetBiDirectionalTableName(instance, instance.OtherSide); instance.Table(tableName); instance.OtherSide.Table(tableName); } } }
public void Apply(IManyToManyCollectionInstance instance) { instance.Access.ReadOnlyPropertyThroughCamelCaseField(); instance.Cascade.SaveUpdate(); instance.AsSet(); instance.BatchSize(25); }
public void Apply(IManyToManyCollectionInstance instance) { var parentName = instance.EntityType.Name; var childName = instance.ChildType.Name; if (parentName.CompareTo(childName) < 0) { instance.Table( string.Format( CultureInfo.InvariantCulture, FluentConfiguration.TableNameTemplate, string.Format( CultureInfo.InvariantCulture, FluentConfiguration.ManyToManyTemplate, Inflector.Pluralize(parentName), Inflector.Pluralize(childName)))); } else { instance.Table( string.Format( CultureInfo.InvariantCulture, FluentConfiguration.TableNameTemplate, string.Format( CultureInfo.InvariantCulture, FluentConfiguration.ManyToManyTemplate, Inflector.Pluralize(childName), Inflector.Pluralize(parentName)))); } }
public void Apply(IManyToManyCollectionInstance instance) { var fkName = $"FK_{instance.EntityType.Name}{instance.OtherSide.EntityType.Name}_{((ICollectionInspector) instance).Name}"; instance.Relationship.ForeignKey(fkName); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Cascade.All(); instance.Key.ForeignKey(string.Format("FK_{0}_{1}", instance.TableName, instance.Relationship.EntityType.Name)); }
public void Apply(IManyToManyCollectionInstance instance) { string keyName = this.GetKeyName(null, instance.EntityType); string columnName = this.GetKeyName(null, instance.ChildType); instance.Key.Column(keyName); instance.Relationship.Column(columnName); }
public void Apply(IManyToManyCollectionInstance instance) { var keyColumn = GetKeyName(null, instance.EntityType); var childColumn = GetKeyName(null, instance.ChildType); instance.Key.Column(keyColumn); instance.Relationship.Column(childColumn); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Key.ForeignKey(string.Format("FK_{0}_{1}", instance.TableName, instance.EntityType.Name)); instance.Key.Column(instance.TableName + "ID"); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Table(string.Format("{0}{1}", instance.EntityType.Name + "s", instance.ChildType.Name + "s")); instance.Key.Column(instance.EntityType.Name + "Id"); instance.Relationship.Column(instance.ChildType.Name + "Id"); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Access.ReadOnlyPropertyThroughCamelCaseField(CamelCasePrefix.Underscore); instance.Cascade.SaveUpdate(); instance.BatchSize(500); instance.AsSet(); instance.LazyLoad(); }
public void Apply(IManyToManyCollectionInstance instance) { Type entityType = instance.EntityType; if (IsEcommerceType(entityType)) { instance.Table(GetTableName(instance.TableName)); } }
public void Apply(IManyToManyCollectionInstance instance) { var childConstraint = GetManyToManyConstraintName(instance.TableName, instance.ChildType.Name); instance.Relationship.ForeignKey(childConstraint); var childConstraint2 = GetManyToManyConstraintName(instance.TableName, instance.EntityType.Name); instance.Key.ForeignKey(childConstraint2); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Key.ForeignKey( string.Format( CultureInfo.InvariantCulture, FluentConfiguration.ForeignKeyTemplate, Inflector.Pluralize(instance.EntityType.Name), Inflector.Pluralize(instance.Member.Name))); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Key.ForeignKey(string.Format("{0}{1}{2}{3}", "FK_", instance.TableName, "_", instance.EntityType.Name)); instance.Key.Column(instance.EntityType.Name + "ID"); instance.Relationship.Column(instance.OtherSide.EntityType.Name + "ID"); }
public void Apply(IManyToManyCollectionInstance instance) { string childConstraint = GetManyToManyConstraintName(instance.TableName, instance.ChildType.Name); instance.Relationship.ForeignKey(childConstraint); string childConstraint2 = GetManyToManyConstraintName(instance.TableName, instance.EntityType.Name); instance.Key.ForeignKey(childConstraint2); }
public void Apply(IManyToManyCollectionInstance instance) { if (instance.OtherSide == null) { instance.Inverse(); instance.Cascade.AllDeleteOrphan(); } else instance.Cascade.AllDeleteOrphan(); }
public void Apply(IManyToManyCollectionInstance instance) { var entityDatabaseName = instance.EntityType.Name.ToDatabaseName(); var childDatabaseName = instance.ChildType.Name.ToDatabaseName(); var name = GetTableName(entityDatabaseName, childDatabaseName); //对两个表名进行排序,然后连接组成中间表名 instance.Table(name); instance.Key.Column(entityDatabaseName + "_ID"); instance.Relationship.Column(childDatabaseName + "_ID"); }
/// <summary> /// Indicate the convetion used to name the Keys on the many to many relations /// </summary> /// <param name="instance">The instance used to get the name for the column</param> public void Apply(IManyToManyCollectionInstance instance) { if (((IManyToManyCollectionInspector)instance.OtherSide).Inverse) { instance.Table(string.Format("{0}For{1}", instance.EntityType.Name, instance.ChildType.Name)); } else { instance.Inverse(); } }
public void Apply(IManyToManyCollectionInstance instance) { var entityName = Inflector.Pluralize(instance.EntityType.Name); var childName = Inflector.Pluralize(instance.ChildType.Name); var tableName = string.Format("{0}X{1}", entityName, childName); instance.Table(tableName); instance.Key.Column(entityName + "ID"); instance.Relationship.Column(childName + "ID"); }
public void Apply(IManyToManyCollectionInstance instance) { var entityType = (typeof(EntityBase).IsAssignableFrom(instance.EntityType) ? instance.EntityType : instance.EntityType.GetFirstAbstractBaseType()).Name; instance.Key.ForeignKey(string.Format("FK_{0}_{1}_{2}", entityType.CleanBaseClassName(), instance.ChildType.Name.CleanBaseClassName(), ((ICollectionInspector)instance).Name.CleanBaseClassName())); }
public void Apply([NotNull] IManyToManyCollectionInstance instance) { Fail.IfArgumentNull(instance, "instance"); instance.Cascade.SaveUpdate(); string fk = "Fk_" + instance.EntityType.Name + "_" + instance.Member.Name; instance.Key.ForeignKey(fk + "_1"); instance.Relationship.ForeignKey(fk + "_2"); }
public void Apply(IManyToManyCollectionInstance instance) { string entityDatabaseName = PersistenceModelGenerator.GetColumnName(instance.EntityType).ToDatabaseName(); string childDatabaseName = PersistenceModelGenerator.GetColumnName(instance.ChildType).ToDatabaseName(); string name = GetTableName(entityDatabaseName, childDatabaseName); instance.Table(name); instance.Key.Column(entityDatabaseName + "_ID"); instance.Relationship.Column(childDatabaseName + "_ID"); instance.Cascade.AllDeleteOrphan(); Debug.WriteLine("----HasManyToManyConvention----"+instance.EntityType+" "+instance.ChildType); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Key.ForeignKey(string.Format("PFK_{0}_{1}", instance.ChildType.Name, instance.EntityType.Name)); //Формирует имя внешнего ключа if (instance.OtherSide == null) //Какая сторона связи многие ко многим обрабатывается? { instance.Relationship.ForeignKey(string.Format("PFK_{0}_{1}", instance.EntityType.Name, instance.Relationship.Class.Name)); //Формирует имя внешнего ключа } else { instance.OtherSide.Key.ForeignKey(string.Format("PFK_{0}_{1}", instance.OtherSide.ChildType.Name, instance.OtherSide.EntityType.Name)); //Формирует имя внешнего ключа } }
public void Apply(IManyToManyCollectionInstance instance) { var names = new List<string> { instance.EntityType.Name, instance.ChildType.Name }; names.Sort(); instance.Table(string.Format("{0}To{1}", names[0], names[1])); instance.LazyLoad(); }
public void Apply(IManyToManyCollectionInstance instance) { var entityDatabaseName = instance.EntityType.Name; var childDatabaseName = instance.ChildType.Name; //之所以要对表格进行排序是为了在生成数据库的时候,不对生成两个连接表。 //例如user 和 group 里面都持有对方的列表。此时会生成两个连接表。但是如果将他们的名字弄成一样,最终 //只会生成一个连接表 var name = "tMap"+ GetTableName(entityDatabaseName,childDatabaseName); //对两个表名进行排序,然后连接组成中间表名 instance.Table(name); instance.Key.Column(entityDatabaseName + "Id"); instance.Relationship.Column(childDatabaseName + "Id"); }
public new void Apply(IManyToManyCollectionInstance instance) { var entityType = instance.EntityType; var childName = instance.ChildType.Name; instance.LazyLoad(); instance.BatchSize(5); instance.Access.CamelCaseField(CamelCasePrefix.Underscore); instance.Cascade.All(); instance.Key.Column(entityType.Name + "_id"); instance.Relationship.Column(Inflector.Underscore(childName) + "_id"); instance.Table(Inflector.Underscore(NamingHelper.GetPrefixedName(entityType) + childName, pluralize: true)); }
public void Apply(IManyToManyCollectionInstance instance) { string entityDatabaseName = PersistenceModelGenerator.GetColumnName(instance.EntityType).ToDatabaseName(); string childDatabaseName = PersistenceModelGenerator.GetColumnName(instance.ChildType).ToDatabaseName(); string name = GetTableName(entityDatabaseName, childDatabaseName); instance.Table(name); instance.Key.Column(entityDatabaseName + "_ID"); instance.Relationship.Column(childDatabaseName + "_ID"); instance.Cascade.AllDeleteOrphan(); Debug.WriteLine("----HasManyToManyConvention----" + instance.EntityType + " " + instance.ChildType); }
public void Apply(IManyToManyCollectionInstance instance) { var entityDatabaseName = instance.EntityType.Name; var childDatabaseName = instance.ChildType.Name; //之所以要对表格进行排序是为了在生成数据库的时候,不对生成两个连接表。 //例如user 和 group 里面都持有对方的列表。此时会生成两个连接表。但是如果将他们的名字弄成一样,最终 //只会生成一个连接表 var name = "tMap" + GetTableName(entityDatabaseName, childDatabaseName); //对两个表名进行排序,然后连接组成中间表名 instance.Table(name); instance.Key.Column(entityDatabaseName + "Id"); instance.Relationship.Column(childDatabaseName + "Id"); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Table(String.Format("{0}{1}s", instance.EntityType.Name, instance.ChildType.Name )); if (instance.Relationship != null) { instance.Relationship.ForeignKey(string.Format("FK_{0}_{1}", instance.TableName, instance.ChildType.Name)); instance.Key.ForeignKey(string.Format("FK_{0}_{1}", instance.TableName, instance.EntityType.Name)); } }
public void Apply(IManyToManyCollectionInstance instance) { if (instance == null) { return; } instance.Key.ForeignKey($"FK_{instance.TableName}_{instance.EntityType.Name}"); if (instance.Member.IsDefined(typeof(RequiredAttribute), false)) { instance.Not.KeyNullable(); } }
/// <summary> /// Apply changes to the target /// </summary> public void Apply(IManyToManyCollectionInstance instance) { string tableName = String.Format("{0}{1}{2}", TableNameConvention.Prefix, instance.EntityType.Name, instance.ChildType.Name); instance.Table(tableName); instance.Key.ForeignKey( String.Format("FK_{0}_{1}", tableName, instance.EntityType.Name)); // How to map foreign key constraint name for child column ?? instance.Key.Column(instance.EntityType.Name + "ID"); instance.Relationship.Column(instance.ChildType.Name + "ID"); }
public void Apply(IManyToManyCollectionInstance instance) { if (instance == null) { return; } var keyColumnAttribute = (ManyToManyAttribute)Attribute.GetCustomAttribute(instance.Member, typeof(ManyToManyAttribute)); if (keyColumnAttribute != null) { instance.Key.Column(instance.EntityType.Name + "ManyRef"); } }
public void Apply(IManyToManyCollectionInstance instance) { instance.Cascade.All(); string theSide = instance.EntityType.Name; string theOtherSide = instance.OtherSide.EntityType.Name; if (theSide.CompareTo(theOtherSide) < 0) { instance.Table(theSide + "_" + theOtherSide + "_Relations"); } else { instance.Table(theOtherSide + "_" + theSide + "_Relations"); } }
public void Apply(IManyToManyCollectionInstance instance) { instance.Cascade.All(); string theSide = instance.EntityType.Name; string theOtherSide = instance.OtherSide.EntityType.Name; if(theSide.CompareTo(theOtherSide) < 0) { instance.Table(theSide + "_" + theOtherSide + "_Relations"); } else { instance.Table(theOtherSide + "_" + theSide + "_Relations"); } }
public void Apply(IManyToManyCollectionInstance instance) { var attr = instance.Member.GetCustomAttribute <LazyLoadAttribute>(); if (attr == null) { return; } if (attr.Enabled) { instance.LazyLoad(); } else { instance.Not.LazyLoad(); } }
public void Apply(IManyToManyCollectionInstance instance) { if (instance.OtherSide == null) { // uni-directional var tableName = GetUniDirectionalTableName(instance); instance.Table(tableName); } else { // bi-directional var tableName = GetBiDirectionalTableName(instance.OtherSide, instance); instance.Table(tableName); instance.OtherSide.Table(tableName); } }
public void Apply(IManyToManyCollectionInstance instance) { var firstName = instance.EntityType.Name; var secondName = instance.ChildType.Name; if (StringComparer.OrdinalIgnoreCase.Compare(firstName, secondName) > 0) { instance.Table(string.Format("{0}{1}", secondName, firstName)); instance.Inverse(); } else { instance.Table(string.Format("{0}{1}", firstName, secondName)); instance.Not.Inverse(); } instance.Cascade.All(); }
public void Apply(IManyToManyCollectionInstance instance) { if (instance.OtherSide == null) { var childConstraint = NameConventions.GetManyToManyForeignKeyConstraintName(instance.EntityType.Name, instance.ChildType.Name, instance.ChildType.Name); instance.Relationship.ForeignKey(childConstraint); var childConstraint2 = NameConventions.GetManyToManyForeignKeyConstraintName(instance.EntityType.Name, instance.ChildType.Name, instance.EntityType.Name); instance.Key.ForeignKey(childConstraint2); } else { var childConstraint = NameConventions.GetManyToManyForeignKeyConstraintName(instance.OtherSide.EntityType.Name, instance.EntityType.Name, instance.ChildType.Name); instance.Relationship.ForeignKey(childConstraint); var childConstraint2 = NameConventions.GetManyToManyForeignKeyConstraintName(instance.OtherSide.EntityType.Name, instance.EntityType.Name, instance.EntityType.Name); instance.Key.ForeignKey(childConstraint2); } }
public void Apply(IManyToManyCollectionInstance instance) { var memberName = NameConverter.ConvertName(instance.Member.Name); var entityName = NameConverter.ConvertName(instance.EntityType.Name); var childTypeName = NameConverter.ConvertName(instance.ChildType.Name); var tableName = string.CompareOrdinal(entityName, childTypeName) < 0 ? string.Format(CultureInfo.InvariantCulture, "{0}_{1}", entityName, childTypeName) : string.Format(CultureInfo.InvariantCulture, "{0}_{1}", childTypeName, entityName); var keyName = string.Format(CultureInfo.InvariantCulture, "fk_{0}_{1}", memberName, entityName); var otherKeyName = string.Format(CultureInfo.InvariantCulture, "fk_{0}_{1}", entityName, memberName); var columnName = string.Format(CultureInfo.InvariantCulture, "{0}_id", entityName); var otherColumnName = string.Format(CultureInfo.InvariantCulture, "{0}_id", childTypeName); instance.Table(tableName); instance.Key.Column(columnName); instance.Key.ForeignKey(keyName); instance.Relationship.Column(otherColumnName); instance.Relationship.ForeignKey(otherKeyName); }
/// <summary> /// Applies this has many to many convention to the specified <see cref = "IManyToManyCollectionInstance" />. /// </summary> /// <param name="instance">An <see cref = "IManyToManyCollectionInstance" />.</param> public void Apply(IManyToManyCollectionInstance instance) { if (instance == null) { throw new ArgumentNullException("instance"); } instance.Key.Column(instance.EntityType.Name + "Id"); instance.Relationship.Column(instance.ChildType.Name + "Id"); instance.AsBag(); instance.Cascade.All(); if (instance.OtherSide == null) { return; } instance.OtherSide.Key.Column(instance.ChildType.Name + "Id"); instance.OtherSide.Relationship.Column(instance.EntityType.Name + "Id"); instance.OtherSide.AsBag(); instance.OtherSide.Cascade.All(); }
public void Apply(IManyToManyCollectionInstance instance) { var naming = new NamingStrategy(); string firstName; string secondName; if (StringComparer.InvariantCultureIgnoreCase.Compare(instance.EntityType.Name, instance.OtherSide.EntityType.Name) > 0) { firstName = instance.EntityType.Name; secondName = instance.OtherSide.EntityType.Name; } else { secondName = instance.EntityType.Name; firstName = instance.OtherSide.EntityType.Name; instance.Not.Inverse(); } instance.Table(naming.Quote( string.Format( "{0}To{1}", Inflector.Inflector.Pluralize(firstName), Inflector.Inflector.Pluralize(secondName)))); }
public void Apply(IManyToManyCollectionInstance instance) { DefaultCascade.All(); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Fetch.Select(); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Table("tbl_" + instance.TableName); }
public void Apply(IManyToManyCollectionInstance instance) { instance.ApplyFilter(FilterName, FilterCondition); }
public void Apply(IManyToManyCollectionInstance instance) { instance.LazyLoad(); // TODO: Do we need ExtraLazyLoad? }
public void Apply(IManyToManyCollectionInstance instance) { }
public void Apply(IManyToManyCollectionInstance instance) { instance.Key.ForeignKey( String.Format("FK_{0}_{1}", instance.Member.Name, instance.EntityType.Name) ); }
public void Apply(IManyToManyCollectionInstance instance) { if (instance.OtherSide != null) if (string.IsNullOrWhiteSpace(((IKeyInspector)instance.Key).ForeignKey)) instance.Key.ForeignKey(string.Format("fk_{0}_{1}", instance.OtherSide.EntityType.Name, instance.EntityType.Name)); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Cache.ReadWrite(); }
public void Apply(IManyToManyCollectionInstance instance) { instance.Cascade.SaveUpdate(); }