ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Potter, Christopher" <christopher.pot...@nfs.fiserv.com>
Subject ExecuteQueryForRowDelegate & ExecuteQueryForMapWithRowDelegate In CachingStatement Class
Date Fri, 12 May 2006 14:59:57 GMT
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;

}

 

Thanks in advance for your input,

Chris Potter

 


Mime
View raw message