/// <summary>
        /// 删除数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entityOfWhere"></param>
        /// <param name="LoptIsAnd"></param>
        /// <returns></returns>
        public string Delete <T>(T entityOfWhere, bool LoptIsAnd)
        {
            string result = "";
            var    conn   = OpenConnection();

            try
            {
                string sql = ModelPropUtils.ModelToDeleteSql(entityOfWhere, LoptIsAnd, out result);
                if (!result.Equals("0"))
                {
                    return(result);
                }

                //conn.Open();
                var res = conn.Execute(sql, entityOfWhere, null, null, null);
                result = "0";// res.ToString();
                conn.Close();
            }
            catch (Exception ex)
            {
                result = $"ex=>{ex.ToString()}";
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(result);
        }
        /// <summary>
        /// 新增数据
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int Insert <T>(T entity, out string result)
        {
            result = "0";
            int idenId = 0;
            var conn   = OpenConnection();

            try
            {
                string sql = ModelPropUtils.ModelToInsertSql(entity, out result);
                if (!result.Equals("0"))
                {
                    result = "=>" + sql;
                    return(0);
                }

                //conn.Open();
                sql   += "SELECT @@identity;";
                idenId = conn.ExecuteScalar <int>(sql, entity);
                //result = res.ToString();
                conn.Close();
            }
            catch (Exception ex)
            {
                result = $"ex=>{ex.ToString()}";
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(idenId);
        }
        /// <summary>
        /// 新增数据(成功返回0)
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public string Insert <T>(T entity)
        {
            string result = "";
            var    conn   = OpenConnection();

            try
            {
                string sql = ModelPropUtils.ModelToInsertSql(entity, out result);
                if (!result.Equals("0"))
                {
                    return(result);
                }

                //conn.Open();
                var res = conn.Execute(sql, entity);
                result = "0";// res.ToString();
                conn.Close();
            }
            catch (Exception ex)
            {
                result = $"ex=>{ex.ToString()}";
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(result);
        }
        /// <summary>
        /// 更新数据-条件
        /// </summary>
        /// <param name="entityToUpdate"></param>
        /// <param name="entityOfWhere"></param>
        /// <param name="LoptIsAnd">逻辑运算符是否为“and”</param>
        /// <returns></returns>
        public string Update <T>(T entityToUpdate, T entityOfWhere, bool LoptIsAnd)
        {
            string result = "";
            var    conn   = OpenConnection();

            try
            {
                /*string sql = ModelPropUtils.ModelToUpDateSql(entityToUpdate, entityOfWhere, LoptIsAnd, out result);
                 * if (!result.Equals("0"))
                 *  return result;
                 *
                 * //conn.Open();
                 * var res = conn.Execute(sql, CombineModel<T>(entityToUpdate, entityOfWhere), null, null, null);
                 * result = "0";// res.ToString();
                 * conn.Close();*/

                string sql = ModelPropUtils.ModelToUpDateSql(entityToUpdate, entityOfWhere, LoptIsAnd, out result);
                if (result.Equals("0"))
                {
                    //conn.Open();
                    var res = conn.Execute(sql, CombineModel <T>(entityToUpdate, entityOfWhere), null, null, null);
                }
                result = "0";// res.ToString();
                conn.Close();
            }
            catch (Exception ex)
            {
                result = $"ex=>{ex.ToString()}";
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(result);
        }
        /// <summary>
        /// 批量Replace数据(成功返回0)
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public string BatchReplace <T>(List <T> entitys)
        {
            string         result = "";
            var            conn   = OpenConnection();
            IDbTransaction trans  = null;

            try
            {
                string sql = ModelPropUtils.ModelToReplaceSqllist(entitys, out result);
                if (!result.Equals("0"))
                {
                    return(result);
                }

                //conn.Open();
                trans = conn.BeginTransaction();
                var res = conn.Execute(sql, entitys, trans);
                trans.Commit();
                result = "0";// res.ToString();
                conn.Close();
            }
            catch (Exception ex)
            {
                if (trans != null)
                {
                    trans.Rollback();
                }
                result = $"ex=>{ex.ToString()}";
            }
            finally
            {
                if (conn.State == System.Data.ConnectionState.Open)
                {
                    conn.Close();
                }
            }

            return(result);
        }