I started a branch a long time ago that I eventually deleted. I took another
stab at it just now (haven't checked in any code anywhere) and ended up making
these changes:
- TypeRegistry.cs: add an alias for "datatable"
- DataExchangeFactory.cs: add _dataRowDataExchange
- ISqlMapper.cs: add QueryForDataTable(string statementName, object
parameterObject) plus delegate member
- ResultClassStrategy.cs: add _dataTableStrategy
- Delegates.cs: added DataTableRowDelegate(DataRow dataRow, object
parameterObject, DataTable dataTable);
- MappedStatement.cs: added RunQueryForDataTable (with DataRowDelegate support
to intercept a created DataRow before its added to the DataTable)
It appears to work ok for a very trivial select statement:
<select id="SelectMany" resultClass="dataTable">
select * from Account
</select>
There still needs to be work done to support resultMaps so you can change the
name of the columns:
<resultMaps>
<resultMap id="AccountResultMap" class="DataTable">
<result property="FirstColumn" columnIndex="0" />
<result property="SecondColumn" columnIndex="1" />
</resultMap>
</resultMaps>
<statements>
<select id="SelectMany" resultMap="AccountResultMap">
select * from Account
</select>
</statements>
DataTable dataTable = sqlMapper.QueryForDataTable("Account.SelectMany", null);
foreach (DataRow dataRow in dataTable.Rows)
{
Console.WriteLine(dataRow["FirstColumn"] + " " + dataRow["SecondColumn"]);
}
ResultProperty.Initialize maybe needs a special case for _isDataTable (line
400-ish)?
----- Original Message ----
From: Vincent Apesa <[EMAIL PROTECTED]>
To: [email protected]
Sent: Sunday, January 21, 2007 8:06:45 AM
Subject: QueryForDataTable()
All,
Has the QueryForDataTable() support been added? It would be nice if
IBatis.Net supported this feature. I saw some discussion last year about this
but never found anything more.
thanks,
Vince