예제 #1
0
        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))));
            }
        }
예제 #2
0
        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)
        {
            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.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");
            }
        }
예제 #5
0
        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");
            }
        }
예제 #6
0
 public void Apply(IManyToManyCollectionInstance instance)
 {
     Type entityType = instance.EntityType;
     if (IsEcommerceType(entityType))
     {
         instance.Table(GetTableName(instance.TableName));
     }
 }
예제 #7
0
 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)
        {
            Type entityType = instance.EntityType;

            if (IsEcommerceType(entityType))
            {
                instance.Table(GetTableName(instance.TableName));
            }
        }
        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);
            }
        }
예제 #10
0
        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)
            {
                // 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);
            }
        }
예제 #12
0
        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();
        }
예제 #13
0
        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");
        }
예제 #14
0
        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");
        }
예제 #15
0
 /// <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();
     }
 }
예제 #16
0
        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 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();
        }
예제 #18
0
        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");
        }
예제 #19
0
        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));
        }
예제 #20
0
        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));
            }
        }
예제 #21
0
        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)
        {
            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);
        }
예제 #23
0
        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");
        }
예제 #24
0
        /// <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");
        }
예제 #25
0
        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);
        }
예제 #26
0
    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))));
    }
예제 #27
0
 /// <summary>
 /// The naming convention for many-to-many tables and constraints
 /// </summary>
 /// <param name="instance"></param>
 public void Apply(IManyToManyCollectionInstance instance)
 {
     instance.Table(GetManyToManyTableName(instance.TableName, instance.OtherSide.TableName));
     instance.Relationship.ForeignKey(string.Format("FK_{0}_{1}", instance.TableName, instance.OtherSide.TableName));
 }
 public void Apply(IManyToManyCollectionInstance instance)
 {
     string tablename = "tbl" + instance.EntityType.Name + "_" + instance.ChildType.Name + "_Relationships";
     instance.Table(tablename);
 }
 public void Apply(IManyToManyCollectionInstance instance)
 {
     instance.Table("tbl_" + instance.TableName);
 }
예제 #30
0
 /// <summary>
 /// The naming convention for many-to-many tables and constraints
 /// </summary>
 /// <param name="instance"></param>
 public void Apply(IManyToManyCollectionInstance instance)
 {
     instance.Table(GetManyToManyTableName(instance.TableName, instance.OtherSide.TableName));
     instance.Relationship.ForeignKey(string.Format("FK_{0}_{1}", instance.TableName, instance.OtherSide.TableName));
 }
예제 #31
0
 public void Apply(IManyToManyCollectionInstance instance)
 {
     instance.Table(string.Format("{0}", instance.TableName.Replace("Entity", "")));
 }