示例#1
0
        /// <summary>
        /// 更新
        /// 使用model中的主键属性作为查询条件;
        /// 使用Where查询条件;
        /// 使用model中的非主键属性作为更新内容;
        /// </summary>
        /// <param name="update_model"></param>
        public virtual void UpdateByPkWhere(OrmBaseModel update_model)
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;

            dao.Update(session, update_model, true);
        }
示例#2
0
        /// <summary>
        /// 删除
        /// 使用model作为查询条件;
        /// </summary>
        /// <param name="query_model"></param>
        public virtual void Delete(OrmBaseModel query_model)
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;

            dao.Delete(session, query_model, true);
        }
示例#3
0
        /// <summary>
        /// 自定义SQL查询
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="sql"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public virtual DataTable UserDefinedQuery(DbConnection conn, DbTransaction dbTransaction, String sql, DbParameter[] parameters)
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;

            return(dao.Select(session, sql, parameters));
        }
示例#4
0
        /// <summary>
        /// 自定义SQL语句,针对UPDATE/DELETE/INSERT
        /// </summary>
        /// <param name="conn"></param>
        /// <param name="dbTransaction"></param>
        /// <param name="sql"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public virtual int UserDefinedSqlNotQuery(DbConnection conn, DbTransaction dbTransaction, String sql, DbParameter[] parameters)
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;

            return(dao.executeSqlNotQuery(conn, dbTransaction, sql, parameters));
        }
示例#5
0
        /// <summary>
        /// 分页查询
        /// 使用model作为查询条件;
        /// 填写mdoel中当前页(current_page)和每页条数(page_item_count)分页信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query_model"></param>
        /// <returns>List<T></returns>
        public virtual List <T> QueryPage <T>(T query_model) where T : OrmBaseModel
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;

            return(dao.SelectPage <T>(session, query_model));
        }
示例#6
0
        /// <summary>
        /// 插入
        /// 使用model作为插入内容;
        /// </summary>
        /// <param name="insert_model"></param>
        public virtual void Insert(OrmBaseModel insert_model)
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;

            dao.Insert(session, insert_model);
        }
示例#7
0
        /// <summary>
        /// 分页查询
        /// 使用model作为查询条件;
        /// 填写mdoel中当前页(current_page)和每页条数(page_item_count)分页信息
        /// </summary>
        /// <param name="query_model"></param>
        /// <returns>DataTable</returns>
        public virtual DataTable QueryPage_DT(OrmBaseModel query_model)
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;

            return(dao.SelectPage(session, query_model));
        }
示例#8
0
        public virtual int QueryNewestRowIndex()
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;
            DataTable res     = udDao.executeSqlQuery(session, mysql_get_max_row_id);

            if (res.Rows[0][0] is System.DBNull)
            {
                return(0);
            }
            return(Convert.ToInt32(res.Rows[0][0]));
        }
示例#9
0
        /// <summary>
        /// 原数据库中存在则更新,不存在则插入
        /// 使用model中的主键属性作为查询条件;
        /// 使用Where查询条件;
        /// 使用model中的非主键属性作为更新内容;
        /// 使用model作为插入内容;
        /// </summary>
        /// <param name="update_model"></param>
        public virtual void UpSertByPk(OrmBaseModel update_model)
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;
            DataTable     rsl     = dao.SelectByPrimaryKey(session, update_model);

            if (rsl.Rows.Count == 1)
            {
                dao.Update(session, update_model, true);
            }
            else
            {
                dao.Insert(session, update_model);
            }
        }
示例#10
0
        /// <summary>
        /// 查询单条
        /// 使用model作为查询条件;
        /// 根据model中的primarykey属性查询;
        /// 根据model中的where属性查询;
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="query_model"></param>
        /// <returns>T</returns>
        public virtual T QueryByPk <T>(T query_model) where T : OrmBaseModel
        {
            ThreadContext t       = LTCingFWSet.GetThreadContext();
            DBSession     session = t.DBSession;
            List <T>      res     = dao.SelectByPrimaryKey <T>(session, query_model);

            if (res.Count == 1)
            {
                return(res[0]);
            }
            else
            {
                return(null);
            }
        }
示例#11
0
        public virtual void QueryValues(string columnID, string startTime, string endTime)
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            ValueInfoOrmModel model = null;

            if (session.ProviderName == DBSession.MySql_ProviderName)
            {
                model = new ValueInfoOrmModel();
            }

            if (model != null)
            {
                model.COLUMN_ID = columnID;
                OrmBaseModel m = (OrmBaseModel)model;

                m.Where = " UPDATE_TIME > '" + startTime + "' AND UPDATE_TIME < '" + endTime + "' ";
                udDao.Select(session, m);
            }
        }
示例#12
0
        public virtual DataTable QueryUDData(OrmBaseModel tbModel)
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.Select(session, tbModel));
        }
示例#13
0
        public virtual int LockRowInfoTable()
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.executeSqlNotQuery(session, mysql_lock_table_write));
        }
示例#14
0
        public virtual List <ValueInfoOrmModel> QueryValueInfo(ValueInfoOrmModel colModel)
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.SelectT <ValueInfoOrmModel>(session, colModel));
        }
示例#15
0
        public virtual int UseUDDB()
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.executeSqlNotQuery(session, mysql_use_db));
        }
示例#16
0
        public virtual int UnLockTables()
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.executeSqlNotQuery(session, mysql_unlock_tables));
        }
示例#17
0
        public virtual int CreateUDMySqlTable()
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.executeSqlNotQuery(session, mysql_create_ud_table));
        }
示例#18
0
        public virtual int InsertUDData(OrmBaseModel tbModel)
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.Insert(session, tbModel));
        }
示例#19
0
        public virtual int DeleteUDData(OrmBaseModel tbModel)
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.Delete(session, tbModel, true));
        }
示例#20
0
        public virtual List <TableInfoOrmModel> QueryTableInfo(TableInfoOrmModel tbModel)
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(udDao.SelectT <TableInfoOrmModel>(session, tbModel));
        }
示例#21
0
        /// <summary>
        /// 查询条数
        /// 使用model作为查询条件;
        /// 查询该条件下的所有条目
        /// </summary>
        /// <param name="query_model"></param>
        /// <returns></returns>
        public virtual int GetItemCount(OrmBaseModel query_model)
        {
            DBSession session = LTCingFWSet.GetThreadContext().DBSession;

            return(dao.GetItemCount(session, query_model));
        }