예제 #1
0
파일: DbCommon.cs 프로젝트: qq5013/yqbbxt
 /// <summary>
 /// 实体类对象参数转换
 /// </summary>
 /// <param name="sqlParams">现有参数</param>
 /// <param name="addParams">增加参数</param>
 /// <returns></returns>
 public static SqlParam[] AddParameter(SqlParam[] sqlParams,SqlParam[] addParams)
 {
     List<SqlParam> sqlparam = new List<SqlParam>(sqlParams);
     foreach (SqlParam param in addParams)
     {
         sqlparam.Add(new SqlParam("@" + param.FieldName, param.FieldValue));
     }
     return sqlparam.ToArray();
 }
예제 #2
0
파일: AspectTest.cs 프로젝트: qq5013/yqbbxt
 public void Test()
 {
     IDataBase DbHelper = DataFactory.GetInstance();
     for (int i = 0; i < 100; i++)
     {
         string AdminID = Public.GetGuID;
         string RoleID = Rand.Number(6);
         string AdminName = "潘向福";
         string strSql = "INSERT INTO CNVP_Admin (AdminID,RoleID,AdminName) VALUES (@AdminID,@RoleID,@AdminName)";
         SqlParam[] Param = new SqlParam[] {
             DbHelper.MakeParam("@AdminID",AdminID),
             DbHelper.MakeParam("@AdminName",AdminName),
             DbHelper.MakeParam("@RoleID",RoleID)
         };
         DbHelper.ExecuteNonQuery(strSql, Param);
     }
     Test2();
 }
예제 #3
0
파일: DbCommon.cs 프로젝트: qq5013/yqbbxt
 /// <summary>
 /// 实体类对象参数转换
 /// </summary>
 /// <param name="model">对象</param>
 /// <param name="sqlParams">参数</param>
 /// <returns></returns>
 public static SqlParam[] GetParameter(object model,SqlParam[] sqlParams)
 {
     DbType dbtype = new DbType();
     Type type = model.GetType();
     PropertyInfo[] props = type.GetProperties();
     List<SqlParam> sqlparam = new List<SqlParam>();
     foreach (PropertyInfo prop in props)
     {
         if (prop.GetValue(model, null) != null)
         {
             if (prop.PropertyType.ToString() == "System.Nullable`1[System.DateTime]")
             {
                 dbtype = DbType.DateTime;
             }
             else
             {
                 dbtype = DbType.AnsiString;
             }
             sqlparam.Add(new SqlParam("@" + prop.Name, dbtype, prop.GetValue(model, null)));
         }
     }
     if (sqlParams != null)
     {
         foreach (SqlParam param in sqlParams)
         {
             sqlparam.Add(new SqlParam(param.FieldName, param.FieldValue));
         }
     }
     return sqlparam.ToArray();
 }