Code/SifCommonFramework/Systemic.Sif.Demo.Publishing.Database/DatabaseRecordIterator.cs
/// <summary>
/// Retrieve StudentPersonal records from the database using the specified SQL query and object mappings
/// defined in the SIFWorks ADK configuration file.
/// </summary>
/// <param name="query">SQL query to run.</param>
/// <returns>StudentPersonal records.</returns>
/// <exception cref="NtAgent.AgentDbException">Error occurred trying to retrieve StudentPersonal records.</exception>
/// <exception cref="System.ArgumentException">query parameter is null or empty.</exception>
Retrieve StudentPersonal records from the database using the specified SQL query and object mappings
defined in the SIFWorks ADK configuration file.
Retrieve StudentPersonal records from the database using the specified SQL query and object mappings defined in the SIFWorks ADK configuration file .
private List<StudentPersonal> GetRecords(String query)
        {
            if (String.IsNullOrEmpty(query))
            {
                throw new ArgumentException("query parameter is null or empty.");
            }
            List<StudentPersonal> records = new List<StudentPersonal>();
            try
            {
                DbProviderFactory dbProviderFactory = DbProviderFactories.GetFactory(databaseDriver);
                using (IDbConnection conn = dbProviderFactory.CreateConnection())
                {
                    conn.ConnectionString = databaseConnectionString;
                    IDbCommand cmd = conn.CreateCommand();
                    cmd.CommandText = query;
                    conn.Open();
                    IDataReader reader = cmd.ExecuteReader();
                    DataReaderAdaptor dataReaderAdaptor = new DataReaderAdaptor(reader);
                    while (reader.Read())
                    {
                        StudentPersonal record = new StudentPersonal();
                        mappings.MapOutbound(dataReaderAdaptor, record);
                        records.Add(record);
                        if (log.IsDebugEnabled) log.Debug(typeof(StudentPersonal).Name + " record retrieved =\n" + record.ToXml());
                    }
                }
            }
            catch (Exception e)
            {
                throw new AgentDbException("Unable to retrieve " + typeof(StudentPersonal).Name + " records via database connection " + databaseConnectionString + " due to the following error: " + e.Message, e);
            }
            return records;
        }
private List < StudentPersonal > GetRecords ( String query ) { if ( String . IsNullOrEmpty ( query ) ) { throw new ArgumentException ( " " ) ; } List < StudentPersonal > records = new List < StudentPersonal > ( ) ; try { DbProviderFactory dbProviderFactory = DbProviderFactories . GetFactory ( databaseDriver ) ; using ( IDbConnection conn = dbProviderFactory . CreateConnection ( ) ) { conn . ConnectionString = databaseConnectionString ; IDbCommand cmd = conn . CreateCommand ( ) ; cmd . CommandText = query ; conn . Open ( ) ; IDataReader reader = cmd . ExecuteReader ( ) ; DataReaderAdaptor dataReaderAdaptor = new DataReaderAdaptor ( reader ) ; while ( reader . Read ( ) ) { StudentPersonal record = new StudentPersonal ( ) ; mappings . MapOutbound ( dataReaderAdaptor , record ) ; records . Add ( record ) ; if ( log . IsDebugEnabled ) log . Debug ( typeof ( StudentPersonal ) . Name + " \n " + record . ToXml ( ) ) ; } } } catch ( Exception e ) { throw new AgentDbException ( " " + typeof ( StudentPersonal ) . Name + " " + databaseConnectionString + " " + e . Message , e ) ; } return records ; }
Retrieve StudentPersonal records from the database using the specified SQL query and object mappings
defined in the SIFWorks ADK configuration file.
Retrieve StudentPersonal records from the database using the specified SQL query and object mappings defined in the SIFWorks ADK configuration file .
None
Error occurred trying to retrieve StudentPersonal records.
Error occurred trying to retrieve StudentPersonal records .
query parameter is null or empty.
query parameter is null or empty .
query
String
SQL query to run.
SQL query to run .