/// <summary>
 /// 修复文本长度
 /// </summary>
 public void RepairByArrayLen()
 {
     foreach (var col in Entity.Properties)
     {
         PropertyBusinessModel model = new PropertyBusinessModel {
             Property = col
         };
         model.RepairByArrayLen();
         col.IsModify = true;
     }
     Entity.IsModify = true;
 }
 /// <summary>
 /// 修复文本长度
 /// </summary>
 public void CheckDouble()
 {
     if (Entity.IsReference)
     {
         return;
     }
     //EntityConfig friend = GetEntity(p => p != Entity && p.Tag == Entity.Tag);
     //if (friend == null)
     //    return;
     foreach (var col in Entity.Properties)
     {
         PropertyBusinessModel model = new PropertyBusinessModel {
             Property = col
         };
         model.CheckDouble();
         col.IsModify = true;
     }
     Entity.IsModify = true;
 }
        /// <summary>
        ///     自动修复(从模型修复数据存储)
        /// </summary>
        public void RepairCpp(bool repair = false)
        {
            if (Entity.IsFreeze)
            {
                return;
            }
            if (Entity.IsReference)
            {
                if (repair)
                {
                    foreach (var col in Entity.Properties)
                    {
                        col.CppLastType = CppTypeHelper2.CppLastType(col.CppType);
                    }
                }
                return;
            }
            RepairEsName(repair);

            EntityConfig friend = GetEntity(p => p != Entity && p.Option.ReferenceTag == Entity.Option.ReferenceTag);

            PropertyBusinessModel model = new PropertyBusinessModel();

            foreach (var col in Entity.Properties)
            {
                if (col.IsDiscard || Entity.IsFreeze)
                {
                    continue;
                }
                col.Parent     = Entity;
                model.Property = col;
                model.RepairCpp(repair, friend);
                col.IsModify = true;
            }
            Entity.IsModify = true;
        }
        /// <summary>
        ///     自动修复(从模型修复数据存储)
        /// </summary>
        public void RepairByModel(bool isReference = false)
        {
            if (Entity.IsFreeze)
            {
                return;
            }
            if (Entity.IsReference)
            {
                foreach (var col in Entity.Properties)
                {
                    col.ColumnName = null;
                    col.DbType     = null;
                }
                Entity.IsModify      = true;
                Entity.IsClass       = true;
                Entity.ReadTableName = null;
                Entity.SaveTableName = null;
                return;
            }
            if (Entity.IsFreeze || Entity.IsReference)
            {
                return;
            }
            RepairCaption();
            if (Entity.IsClass)
            {
                Entity.ReadTableName = null;
                Entity.SaveTableName = null;
            }
            else
            {
                if (string.IsNullOrWhiteSpace(Entity.ReadTableName))
                {
                    Entity.ReadTableName = ToWords(Entity.Name).LinkToString("tb_", "_");
                }
                if (Entity.PrimaryColumn == null)
                {
                    Entity.Properties.Add(new PropertyConfig
                    {
                        Name         = Entity.Name + "Id",
                        Caption      = Entity.Caption + "ID",
                        Description  = Entity.Caption + "ID",
                        IsPrimaryKey = true,
                        IsIdentity   = true,
                        CsType       = "int",
                        CppType      = "int",
                        Parent       = Entity
                    });
                }
            }
            EntityConfig friend = GetEntity(p => p != Entity && p.Tag == Entity.Tag);

            PropertyBusinessModel model = new PropertyBusinessModel();

            foreach (var col in Entity.Properties)
            {
                if (col.Discard || col.IsFreeze)
                {
                    continue;
                }
                col.Parent     = Entity;
                model.Property = col;
                model.RepairByModel(isReference, friend);
                col.IsModify = true;
            }
            Entity.IsModify = true;
        }