//按需更新--界面上只修改了几个字段--大家有什么思路,可以自己动手,然后show出来
        //1 传递一个列表---实体三个属性  字段名称--操作符--值
        //2 改造成json---{"Name":"zzzz","Password":"******"}
        public int Update <T>(string json, int id) where T : BaseEntity, new()
        {
            Type   type      = typeof(T);
            T      t         = Newtonsoft.Json.JsonConvert.DeserializeObject <T>(json);//JObject
            string stringSet = string.Join(",", type.GetPropertiesInJson(json).Select(p => $"{p.GetMappingName()}=@{p.Name}"));
            string sql       = $"UPDATE {type.GetMappingName()} SET {stringSet} WHERE Id=@Id;";

            var paraArray = type.GetPropertiesInJson(json).Select(p => new SqlParameter($"@{p.Name}", p.GetValue(t) ?? DBNull.Value)).Append(new SqlParameter("@Id", id)).ToArray();

            string connString = SqlConnectionPool.GetOtherDbConnectionString(SqlConnectionPool.SqlConnectionType.Write);

            using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand command = new SqlCommand(sql, conn);
                command.Parameters.AddRange(paraArray);
                conn.Open();
                return(command.ExecuteNonQuery());
            }
        }
        public bool Delete <T>(T t) where T : BaseEntity, new()
        {
            Type   type      = t.GetType();
            string sql       = $"DELETE FROM [{type.GetMappingName()}] WHERE Id=@Id;";
            var    paraArray = new SqlParameter[] { new SqlParameter("@Id", t.Id) };

            string connString = SqlConnectionPool.GetOtherDbConnectionString(SqlConnectionPool.SqlConnectionType.Write);

            using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand command = new SqlCommand(sql, conn);
                command.Parameters.AddRange(paraArray);
                conn.Open();
                //var trans = conn.BeginTransaction();
                //trans.Commit();
                //trans.Rollback();
                return(1 == command.ExecuteNonQuery());
            }
        }
        public int Update <T>(T t) where T : BaseEntity, new()
        {
            if (!t.Validate <T>())
            {
                throw new Exception("数据校验没有通过");//大家可以再返回点提示信息
            }

            Type   type      = t.GetType();
            string stringSet = string.Join(",", type.GetPropertiesWithoutKey().Select(p => $"{p.GetMappingName()}=@{p.Name}"));
            string sql       = $"UPDATE [{type.GetMappingName()}] SET {stringSet} WHERE Id=@Id;";
            //string sql = SqlBuilder<T>.GetInsertSql();
            var paraArray = type.GetProperties().Select(p => new SqlParameter($"@{p.Name}", p.GetValue(t) ?? DBNull.Value)).ToArray();

            string connString = SqlConnectionPool.GetOtherDbConnectionString(SqlConnectionType.Write);

            using (SqlConnection conn = new SqlConnection(connString))
            {
                SqlCommand command = new SqlCommand(sql, conn);
                command.Parameters.AddRange(paraArray);
                conn.Open();
                return(command.ExecuteNonQuery());
            }
        }