Esempio n. 1
0
        /// <summary>
        /// 添加单条数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual object Insert <T>(T entity)
        {
            object result   = null;
            var    dbEntity = DbBuilder.Insert <T>(entity);

            if (dbEntity == null)
            {
                return(result);
            }
            if (!dbEntity.TableEntity.IsGetAutoIncrementValue)
            {
                result = DbHelper.ExecuteNonQuery(dbEntity.CommandText, dbEntity.DbParams);
            }
            else
            {
                var dbTypeValue = Convert.ToInt32(CurrentDbType);
                switch (dbTypeValue)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                    result = ExecuteScalar(dbEntity.CommandText, dbEntity.DbParams);
                    break;
                }
            }
            HandelExecuteDbCallBack(dbEntity.CommandText, dbEntity.DbParams);
            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 添加单条实体对象数据
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="entity"></param>
        /// <returns></returns>
        public virtual object Insert <T>(T entity)
        {
            object result   = default(object);
            var    dbEntity = DbBuilder.Insert <T>(entity);

            if (dbEntity == null)
            {
                return(result);
            }
            result = dbEntity.TableEntity.IsGetIncrementValue ?
                     DbHelper.ExecuteScalar(dbEntity.CommandText, dbEntity.DbParams) :
                     DbHelper.ExecuteNonQuery(dbEntity.CommandText, dbEntity.DbParams);
            return(result);
        }