예제 #1
0
        /// <summary>
        /// 失败表示存在更新影响条数为0的update
        /// </summary>
        public override bool UpdateAll <T>(DbQueryBuilder queryBuilder)
        {
            bool      result  = true;
            DbCommand command = Session.CreateCommand();

            foreach (var updateBuilder in queryBuilder.UpdateBuilders)
            {
                command.CommandText = updateBuilder.ToQueryString(Session, new T().TableName);
                updateBuilder.AddParameter(command, Session);
                WriteQueryLog(command, Session);
                result = result && Session.ExecuteNonQuery(command) > 0;
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 提供对应数据库的数据库语句构建类
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        public static DbQueryBuilder GetDbQueryBuilder(this DbSession session)
        {
            DbQueryBuilder result;

            switch (session.DatabaseType)
            {
            case EDatabaseType.MSSQL:
            case EDatabaseType.MySQL:    //TODO MySQL暂时启用MSSQL方案
            case EDatabaseType.SQLite:   // TODO SQLite暂时启用MSSQL方案
                result = new DbQueryBuilder();
                break;

            case EDatabaseType.Oracle:
            //TODO 未支持多数据库
            default:
                throw new NotImplementedException("未实现该类别的QueryBuilder" + session.DatabaseType);
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// 失败表示影响数据为0
        /// </summary>
        public override bool Delete <T>(DbQueryBuilder queryBuilder)
        {
            var deleteBuilder = queryBuilder.DeleteBuilder;

            return(Delete <T>(deleteBuilder));
        }
예제 #4
0
 /// 组合查询
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="Session"></param>
 /// <param name="queryBuilder"></param>
 /// <returns></returns>
 public override List <T> SelectUnion <T>(DbQueryBuilder queryBuilder)
 {
     throw new NotImplementedException();
 }
예제 #5
0
        /// <summary>
        /// 失败返回 new List<T>()
        /// </summary>
        public override List <T> SelectAll <T>(DbQueryBuilder queryBuilder)
        {
            SelectBuilder selectBuilder = queryBuilder.SelectBuilders.First();

            return(SelectAll <T>(selectBuilder));
        }
예제 #6
0
        /// <summary>
        /// 返回 是否成功新增
        /// </summary>
        public override bool Insert <T>(DbQueryBuilder queryBuilder)
        {
            var insertBuilder = queryBuilder.InsertBuilders.First();

            return(Insert <T>(insertBuilder));
        }
예제 #7
0
        /// <summary>
        /// 失败返回null
        /// </summary>
        public override T Select <T>(DbQueryBuilder queryBuilder)
        {
            SelectBuilder selectBuilder = queryBuilder.SelectBuilders.FirstOrDefault();

            return(Select <T>(selectBuilder));
        }
예제 #8
0
        /// <summary>
        /// 失败表示存在更新影响条数为0的update
        /// </summary>
        public override bool Update <T>(DbQueryBuilder queryBuilder)
        {
            var updateBuilder = queryBuilder.UpdateBuilders.First();

            return(Update <T>(updateBuilder));
        }
예제 #9
0
 /// <summary>
 /// 返回 是否有数据受操作影响
 /// </summary>
 public abstract bool Insert <T>(DbQueryBuilder queryBuilder) where T : VLModel_DB, new();
예제 #10
0
        public abstract List <T> SelectAll <T>() where T : VLModel_DB, new();//IDbSession session

        /// <summary>
        /// 未查询到数据时返回 New List()
        /// 多个SelectBuilder组合查询
        /// </summary>
        public abstract List <T> SelectUnion <T>(DbQueryBuilder queryBuilder) where T : VLModel_DB, new();
예제 #11
0
 /// <summary>
 /// 未查询到数据时返回 null
 /// </summary>
 public abstract T Select <T>(DbQueryBuilder queryBuilder) where T : VLModel_DB, new();
예제 #12
0
 /// <summary>
 /// 返回 是否有数据受操作影响
 /// </summary>
 public abstract bool UpdateAll <T>(DbQueryBuilder queryBuilder) where T : VLModel_DB, new();
예제 #13
0
 /// <summary>
 /// 返回 是否有数据受操作影响
 /// </summary>
 public abstract bool Delete <T>(DbQueryBuilder queryBuilder) where T : VLModel_DB, new();