예제 #1
0
파일: Query.cs 프로젝트: Atulin/DerpiViewer
 // Override GetHashCode() method
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Tags != null ? Tags.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (QueryStr != null ? QueryStr.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #2
0
        /// <summary>
        ///  insert Object 'obj' to table 'tablename'
        /// </summary>
        /// <param name="tablename"></param>
        /// <param name="obj"></param>
        /// <returns></returns>
        public ResponseBase Add(string tablename, dynamic obj)
        {
            var responseBase = new ResponseBase();
            // myDict is the object that we convert from dynamic "obj"
            var      objDict      = HelperDataUtilities.ToDictionary(obj);
            QueryStr query        = HelperDataUtilities.ToInsertString(objDict);
            var      dbConnection = new DBConnection();

            dbConnection.conn.Open();
            var list = new List <ProcedureParams>();

            list.Add(new ProcedureParams("@p_table_name", tablename, ParameterDirection.Input));
            list.Add(new ProcedureParams("@p_attr", query.AttrStr, ParameterDirection.Input));
            list.Add(new ProcedureParams("@p_val", query.ValStr, ParameterDirection.Input));
            try
            {
                var result = this.CallStoreProcedure("HelperAdd", list, dbConnection.conn).ExecuteNonQuery();
                responseBase.success = true;
                responseBase.message = "success";
            }
            catch (Exception ex)
            {
                responseBase.success = false;
                responseBase.message = "error";
                responseBase.error   = new ErrorResponseBase()
                {
                    message = ex.Message,
                    errCode = ex.StackTrace.ToString()
                };
            }
            finally
            {
                dbConnection.conn.Close();
            }
            return(responseBase);
        }