Provide QueryWithRowDelegate that accepts a list resultObject
-------------------------------------------------------------
Key: IBATISNET-205
URL: https://issues.apache.org/jira/browse/IBATISNET-205
Project: iBatis for .NET
Issue Type: Improvement
Components: DataMapper
Reporter: Ron Grabowski
Priority: Minor
The RunQueryForList method in MappedStatement.cs accepts a resultObject as well
as a row delegate. There isn't an matching method in the ISqlMapper interface.
When writing code like this:
public UserInfo[] AllUsers
{
get
{
List<UserInfo> result =
(List<UserInfo>)sqlMapper.QueryWithRowDelegate<UserInfo>("UserInfo.AllUsers",
null, new RowDelegate<UserInfo>(setUsersStorageProvider));
return result.ToArray();
}
}
private void setUsersStorageProvider(object obj, object parameterObject,
IList<UserInfo> list)
{
UserInfo userInfo = (UserInfo)obj;
userInfo.Provider = this;
list.Add(userInfo);
}
You have to cast to List<T> in order to return UserInfo[]. Passing in a list to
fill would remove the cast:
List<UserInfo> result = new List<UserInfo>;
sqlMapper.QueryWithRowDelegate<UserInfo>("UserInfo.AllUsers", null, result, new
RowDelegate<UserInfo>(setUsersStorageProvider));
return result.ToArray();
I don't know how that would affect caching.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira