A very basic QueryForDataTable might look like this: // untested public static DataTable QueryForDataTable(this ISqlMapper sqlMapper, string statement, object parameter) { var dataTableRowDelegate = new QueryWithRowDelegateDataTable(); sqlMapper.QueryWithRowDelegate(statement, parameter, dataTableRowDelegate.RowDelegate); return dataTableRowDelegate.DataTable; }
// untested public class QueryWithRowDelegateDataTable { private readonly DataTable _dataTable = new DataTable(); private bool _firstRow = true; public void RowDelegate(object obj, object parameterObject, IList unused) { object[] items = (object[])obj; if (_firstRow) { for (int i = 0; i < items.Length; i++) { _dataTable.Columns.Add("DataColumn" + i, items[i].GetType()); } _firstRow = false; } _dataTable.Rows.Add(items); } public DataTable DataTable { get { return _dataTable; } } } To get the DataTable's column names to match the names of the database column you'd need to hook into MappedStatement. ________________________________ From: Michael McCurrey <mmccur...@gmail.com> To: user-cs@ibatis.apache.org Sent: Monday, June 22, 2009 9:28:48 AM Subject: Next Release Ok folks, I'd like to plan the next release of iBatis and would like to know "What do you want?" I would like to make a few small releases to bridge the 1.X line & the existing 3.X line due to the number of breaking changes in the 3.X line. Some things I want to do for 'just me' are: 1. Feature match the Java version 2. Fix an annoying list non lazy load bug 3. Rev to my Castle.DynamicProxy2 patch 4. Expose a QueryForDataTable 5. Drop .net 1.X compatibility. 6. Lastly, I would like something ambitious like Orin's Binsor for Castle on the configuration front. -- Michael