private static void ToLightweightAgentStatus <T>(string sqlStatement, Action <IAgentStatus> loopingDelegate, Func <T> newInstance) where T : IAgentStatus { var reader = NHibernateManager.ExecuteReader(sqlStatement); while (reader.Read()) { var time = reader.GetDateTime(0); var extNo = reader.GetString(1); var agentAcdid = reader.GetString(2); var option = reader[3]; //loopingDelegate(new T().SetProperties(time, extNo, agentAcdid, option)); old loopingDelegate(newInstance().SetProperties(time, extNo, agentAcdid, option)); } NHibernateManager.CloseReader(reader); }