public object Clone()
        {
            CloneRelationDefInfo other = (CloneRelationDefInfo)this.MemberwiseClone();

            other.m_RelationFields  = this.m_RelationFields.Select((rf) => ((CloneRelationFieldDef)rf.Clone())).ToList();
            other.m_strName         = this.m_strName;
            other.m_strTable        = this.m_strTable;
            other.m_strColumn       = this.m_strColumn;
            other.m_strForeignTable = this.m_strForeignTable;
            other.m_lAttributes     = this.m_lAttributes;
            other.m_nFields         = this.m_nFields;

            return(other);
        }
        public static void ConvertRelation(CloneTableDefInfo tableInfo, CloneRelationDefInfo relation, IList <string> namesOfRelations, IList <CloneTableDefInfo> tableList)
        {
            var relationTable = TableInfoByName(tableList, relation.m_strForeignTable);

            if (relationTable != null)
            {
                string constraintName = CreateRelationNameMxToId(tableInfo, relation, relationTable, namesOfRelations);

                var targetColumn = relationTable.SourceFieldByName(constraintName);

                if (targetColumn == null)
                {
                    relationTable.CreateTargetField(constraintName, DBConstants.DB_LONG, DBConstants.dbNullFieldOption);
                }

                relation.MakeTargetRelationOrmReady(constraintName, COLUMN_NAME_AUTOID);
            }
        }
        private static string CreateRelationNameMxToId(CloneTableDefInfo tableInfo, CloneRelationDefInfo relation, CloneTableDefInfo relationTable, IList <string> relationNames)
        {
            string uniqueXPkName = tableInfo.TargetPKUniqueAllNames();

            string uniqueRPkName = relationTable.TargetPKUniqueAllNames();

            string uniqueForName = relation.TargetForeignNamestAllUnique();

            string uniqueRelName = relation.TargetNamestAllUnique();

            string[] columnsNames      = uniqueForName.Split(new char[] { '.' });
            int      columnsNamesCount = columnsNames.Length;

            string[] colRelsNames      = uniqueRelName.Split(new char[] { '.' });
            int      colRelsNamesCount = colRelsNames.Length;
            string   uniqueRelXEnds    = colRelsNames[colRelsNamesCount - 1];

            int realtionNameCount = relationNames.Count((rn) => (rn.CompareTo(uniqueForName) == 0));

            string constraintName = relation.m_strName.ToLower() + NAMEAUTO_REF_ID;

            if (uniqueXPkName.CompareTo(uniqueRelName) != 0)
            {
                if (uniqueRelXEnds.CompareTo("id") == 0)
                {
                    constraintName = columnsNames[columnsNamesCount - 1];
                }
                else if (uniqueRelXEnds.CompareTo("firma_id") == 0)
                {
                    constraintName = relation.m_strTable.ToLower() + NAMEAUTO_REF_ID;
                }
                else if (uniqueRelXEnds.EndsWith("kod"))
                {
                    string constraintColl = columnsNames[columnsNamesCount - 1];
                    constraintName = CreateConstraintName(constraintColl, "kod", NAMEAUTO_REF_ID);
                }
                else if (uniqueRelXEnds.Contains("kod"))
                {
                    string constraintColl = columnsNames[columnsNamesCount - 1];
                    constraintName = CreateConstraintName(constraintColl, "kod", NAMEAUTO_REF_ID);
                }
                else if (uniqueRelXEnds.EndsWith("cislo"))
                {
                    string constraintColl = columnsNames[columnsNamesCount - 1];
                    constraintName = CreateConstraintName(constraintColl, "cislo", NAMEAUTO_REF_ID);
                }
                else if (uniqueRelXEnds.Contains("cislo"))
                {
                    string constraintColl = columnsNames[columnsNamesCount - 1];
                    constraintName = CreateConstraintName(constraintColl, "cislo", NAMEAUTO_REF_ID);
                }
                else if (uniqueRelXEnds.EndsWith("id"))
                {
                    string constraintColl = columnsNames[columnsNamesCount - 1];
                    constraintName = CreateConstraintName(constraintColl, "id", NAMEAUTO_REF_ID);
                }
                else if (uniqueRelXEnds.Contains("id"))
                {
                    string constraintColl = columnsNames[columnsNamesCount - 1];
                    constraintName = CreateConstraintName(constraintColl, "id", NAMEAUTO_REF_ID);
                }
                else if (uniqueRelXEnds.CompareTo("mesic") == 0)
                {
                    constraintName = relation.m_strTable.ToLower() + NAMEAUTO_REF_ID;
                }
                else
                {
                    string constraintColl = columnsNames[columnsNamesCount - 1];
                    constraintName = constraintColl + NAMEAUTO_REF_ID;
                }
            }
            else
            {
                constraintName = columnsNames[columnsNamesCount - 1];
            }

            return(constraintName);
        }