/// <summary> /// 使用 Sql 进行查询。 /// 分页默认实现为使用内存进行分页。 /// </summary> /// <param name="dba">The dba.</param> /// <param name="args">The arguments.</param> public virtual void QueryTable(IDbAccesser dba, ITableQueryArgs args) { if (_hasLOB) { args.FormattedSql = this.ReplaceLOBColumns(args.FormattedSql); } using (var reader = dba.QueryDataReader(args.FormattedSql, args.Parameters)) { var table = args.ResultTable; if (table.Columns.Count == 0) { LiteDataTableAdapter.AddColumns(table, reader); } var columnsCount = table.Columns.Count; PagingHelper.MemoryPaging(reader, r => { var row = table.NewRow(); for (int i = 0; i < columnsCount; i++) { var value = reader[i]; if (value != DBNull.Value) { row[i] = value; } } table.Rows.Add(row); }, args.PagingInfo); } }
public override void QueryTable(IDbAccesser dba, ITableQueryArgs args) { var pagingInfo = args.PagingInfo; if (PagingInfo.IsNullOrEmpty(pagingInfo) || this.GetPagingLocation(pagingInfo) == PagingLocation.Memory) { base.QueryTable(dba, args); } else { //转换为分页查询 SQL var parts = ParsePagingSqlParts(args.FormattedSql); CreatePagingSql(ref parts, pagingInfo); //读取分页的数据 var table = args.ResultTable; var reader = dba.QueryDataReader(parts.PagingSql, args.Parameters); using (reader) { LiteDataTableAdapter.Fill(table, reader); } QueryTotalCountIf(dba, pagingInfo, parts, args.Parameters); } }
public override void QueryTable(IDbAccesser dba, ITableQueryArgs args) { var pagingInfo = args.PagingInfo; if (PagingInfo.IsNullOrEmpty(pagingInfo) || this.GetPagingLocation(pagingInfo) == PagingLocation.Memory) { base.QueryTable(dba, args); } else { //转换为分页查询 SQL var parts = ParsePagingSqlParts(args.FormattedSql); CreatePagingSql(ref parts, pagingInfo); //读取分页的数据 var table = args.ResultTable; using (var reader = dba.QueryDataReader(parts.PagingSql, args.Parameters)) { LiteDataTableAdapter.Fill(table, reader); } QueryTotalCountIf(dba, pagingInfo, parts, args.Parameters); } }