Beispiel #1
0
        /// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/2/23 15:26:55</remarks>
        public bool Update(DicMailEntity entity, DbTransaction trans)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_DicMail_Update");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx);
            database.AddInParameter(commandWrapper, "@Category", DbType.Int32, entity.Category);
            database.AddInParameter(commandWrapper, "@SourceType", DbType.Int32, entity.SourceType);
            database.AddInParameter(commandWrapper, "@Title", DbType.String, entity.Title);
            database.AddInParameter(commandWrapper, "@ContentTemplate", DbType.String, entity.ContentTemplate);
            database.AddInParameter(commandWrapper, "@ContentParam", DbType.AnsiString, entity.ContentParam);
            database.AddInParameter(commandWrapper, "@HasAttach", DbType.Boolean, entity.HasAttach);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }


            return(Convert.ToBoolean(results));
        }
Beispiel #2
0
        /// <summary>
        /// 将IDataReader的当前记录读取到DicMailEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public DicMailEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new DicMailEntity();

            obj.Idx             = (System.Int32)reader["Idx"];
            obj.Category        = (System.Int32)reader["Category"];
            obj.SourceType      = (System.Int32)reader["SourceType"];
            obj.Title           = (System.String)reader["Title"];
            obj.ContentTemplate = (System.String)reader["ContentTemplate"];
            obj.ContentParam    = (System.String)reader["ContentParam"];
            obj.HasAttach       = (System.Boolean)reader["HasAttach"];

            return(obj);
        }
Beispiel #3
0
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="idx">idx</param>
        /// <returns>DicMailEntity</returns>
        /// <remarks>2016/2/23 15:26:55</remarks>
        public DicMailEntity GetById(System.Int32 idx)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_DicMail_GetById");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx);


            DicMailEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Beispiel #4
0
 /// <summary>
 /// Update
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 /// <remarks>2016/2/23 15:26:55</remarks>
 public bool Update(DicMailEntity entity)
 {
     return(Update(entity, null));
 }
Beispiel #5
0
 /// <summary>
 /// Insert
 /// </summary>
 /// <param name="entity"></param>
 /// <param name="trans">The trans.</param>
 /// <returns></returns>
 /// <remarks>2016/2/23 15:26:55</remarks>
 public bool Insert(DicMailEntity entity)
 {
     return(Insert(entity, null));
 }
Beispiel #6
0
        public static bool Update(DicMailEntity dicMailEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new DicMailProvider(zoneId);

            return(provider.Update(dicMailEntity, trans));
        }