/// <summary> /// /// </summary> /// <typeparam name="T"></typeparam> /// <typeparam name="TCollection"></typeparam> /// <param name="qc"></param> /// <param name="rowToObject"></param> /// <param name="totalCount"></param> /// <returns></returns> public TCollection SplitPageQuery <T, TCollection>(QueryCondition qc, Action <TCollection, DataRow> rowToObject, ref int totalCount) where T : new() where TCollection : EditableDataObjectCollectionBase <T>, new() { qc.NullCheck("qc"); rowToObject.NullCheck("rowToObject"); DataSet ds = this.SplitPageQuery(qc, totalCount <= 0); TCollection result = new TCollection(); foreach (DataRow row in ds.Tables[0].Rows) { rowToObject(result, row); } if (ds.Tables.Count > 1) { totalCount = (int)ds.Tables[1].Rows[0][0]; } //当页码超出索引的,返回最大页 if (result.Count == 0 && totalCount > 0) { int newStartRowIndex = (totalCount - 1) / qc.PageSize * qc.PageSize; totalCount = -1; qc.RowIndex = newStartRowIndex; result = SplitPageQuery <T, TCollection>(qc, rowToObject, ref totalCount); } return(result); }