ExecuteQueryForRowDelegate & ExecuteQueryForMapWithRowDelegate In 
CachingStatement Class
----------------------------------------------------------------------------------------

         Key: IBATISNET-157
         URL: http://issues.apache.org/jira/browse/IBATISNET-157
     Project: iBatis for .NET
        Type: Improvement

  Components: DataMapper  
    Versions: DataMapper 1.3    
    Reporter: Chris Potter


Hi All:

 

I'd like to propose the following changes to the 2 methods described in the 
Subject above.  Please let me know your thoughts on this proposed change.  I 
realize it requires iteration through the cached result collection after 
retrieving the collection from the cache.  This still, however, seems to 
provide a measurable performance benefit over going to the database each time 
the query is executed.

 

public IList ExecuteQueryForRowDelegate(IDalSession session, object 
parameterObject, SqlMapper.RowDelegate rowDelegate)

{

      //Original code:  return 
_mappedStatement.ExecuteQueryForRowDelegate(session, parameterObject, 
rowDelegate);

         IList list = this.ExecuteQueryForList(session, parameterObject);

         IList delegateList = new ArrayList(list.Count);

 

         foreach (object obj in list)

         {

            rowDelegate(obj, parameterObject, delegateList);

         }

 

         return delegateList;

}

 

 

public IDictionary ExecuteQueryForMapWithRowDelegate(IDalSession session, 
object parameterObject, string keyProperty, string valueProperty, 
SqlMapper.DictionaryRowDelegate rowDelegate)

{

      //Original code: return 
_mappedStatement.ExecuteQueryForMapWithRowDelegate(session, parameterObject, 
keyProperty, valueProperty, rowDelegate);

 

         IDictionary map = this.ExecuteQueryForMap(session, parameterObject, 
keyProperty, valueProperty);

         IDictionary delegateMap = new Hashtable(map.Count);

 

         foreach (object obj in map.Values)

         {

            object key = ObjectProbe.GetPropertyValue(obj, keyProperty);

            object value = obj;

            if (valueProperty != null)

            {

               value = ObjectProbe.GetPropertyValue(obj, valueProperty);

            }

 

            rowDelegate(key, value, parameterObject, delegateMap);

         }

 

         return delegateMap;

}

 



-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to