protected override UserSessionType LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             UserSessionTypeTable.GetColumnNames("[ust]") +
                             " FROM [core].[UserSessionType] AS [ust] ";
                sqlCmdText += "WHERE [ust].[UserSessionTypeID] = @UserSessionTypeID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@UserSessionTypeID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("ust", "loadinternal", "notfound"), "UserSessionType could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                UserSessionTypeTable ustTable = new UserSessionTypeTable(query);


                UserSessionType ustObject = ustTable.CreateInstance();
                sqlReader.Close();

                return(ustObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("ust", "loadinternal", "exception"), "UserSessionType could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "UserSessionType", "Exception while loading UserSessionType object from database. See inner exception for details.", ex);
            }
        }
示例#2
0
        public List <Customer> LoadMany(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             CustomerTable.GetColumnNames("[c]") +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[c_u_ut]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[c_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[c_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[c_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[c_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[c_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[c_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[c_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CountryTable.GetColumnNames("[c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[c_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_mo_c]") : string.Empty) +
                             " FROM [core].[Customer] AS [c] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [c_u] ON [c].[UserID] = [c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserType] AS [c_u_ut] ON [c_u].[UserTypeID] = [c_u_ut].[UserTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [c_s] ON [c].[ServiceID] = [c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [c_s_a] ON [c_s].[ApplicationID] = [c_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [c_s_p] ON [c_s].[ProductID] = [c_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [c_s_m] ON [c_s].[MerchantID] = [c_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [c_s_st] ON [c_s].[ServiceTypeID] = [c_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [c_s_ust] ON [c_s].[UserSessionTypeID] = [c_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_s_c] ON [c_s].[FallbackCountryID] = [c_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [c_s_l] ON [c_s].[FallbackLanguageID] = [c_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [c_s_sc] ON [c_s].[ServiceConfigurationID] = [c_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [c_s_t] ON [c_s].[TemplateID] = [c_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_c] ON [c].[CountryID] = [c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_c_l] ON [c_c].[LanguageID] = [c_c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_l] ON [c].[LanguageID] = [c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [c_mo] ON [c].[MobileOperatorID] = [c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [c_mo_c] ON [c_mo].[CountryID] = [c_mo_c].[CountryID] ";
                }


                sqlCmdText = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "customloadmany", "notfound"), "Customer list could not be loaded using custom logic as no items were found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(new List <Customer>());
                }

                SqlQuery query = new SqlQuery(sqlReader);

                CustomerTable             cTable       = new CustomerTable(query);
                UserTable                 c_uTable     = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable             c_u_utTable  = (this.Depth > 1) ? new UserTypeTable(query) : null;
                ServiceTable              c_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          c_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              c_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             c_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          c_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      c_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              c_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             c_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable c_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             c_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CountryTable              c_cTable     = (this.Depth > 0) ? new CountryTable(query) : null;
                LanguageTable             c_c_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                LanguageTable             c_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                MobileOperatorTable       c_moTable    = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable              c_mo_cTable  = (this.Depth > 1) ? new CountryTable(query) : null;

                List <Customer> result = new List <Customer>();
                do
                {
                    UserType             c_u_utObject  = (this.Depth > 1) ? c_u_utTable.CreateInstance() : null;
                    User                 c_uObject     = (this.Depth > 0) ? c_uTable.CreateInstance(c_u_utObject) : null;
                    Application          c_s_aObject   = (this.Depth > 1) ? c_s_aTable.CreateInstance() : null;
                    Product              c_s_pObject   = (this.Depth > 1) ? c_s_pTable.CreateInstance() : null;
                    Merchant             c_s_mObject   = (this.Depth > 1) ? c_s_mTable.CreateInstance() : null;
                    ServiceType          c_s_stObject  = (this.Depth > 1) ? c_s_stTable.CreateInstance() : null;
                    UserSessionType      c_s_ustObject = (this.Depth > 1) ? c_s_ustTable.CreateInstance() : null;
                    Country              c_s_cObject   = (this.Depth > 1) ? c_s_cTable.CreateInstance() : null;
                    Language             c_s_lObject   = (this.Depth > 1) ? c_s_lTable.CreateInstance() : null;
                    ServiceConfiguration c_s_scObject  = (this.Depth > 1) ? c_s_scTable.CreateInstance() : null;
                    Template             c_s_tObject   = (this.Depth > 1) ? c_s_tTable.CreateInstance() : null;
                    Service              c_sObject     = (this.Depth > 0) ? c_sTable.CreateInstance(c_s_aObject, c_s_pObject, c_s_mObject, c_s_stObject, c_s_ustObject, c_s_cObject, c_s_lObject, c_s_scObject, c_s_tObject) : null;
                    Language             c_c_lObject   = (this.Depth > 1) ? c_c_lTable.CreateInstance() : null;
                    Country              c_cObject     = (this.Depth > 0) ? c_cTable.CreateInstance(c_c_lObject) : null;
                    Language             c_lObject     = (this.Depth > 0) ? c_lTable.CreateInstance() : null;
                    Country              c_mo_cObject  = (this.Depth > 1) ? c_mo_cTable.CreateInstance() : null;
                    MobileOperator       c_moObject    = (this.Depth > 0) ? c_moTable.CreateInstance(c_mo_cObject) : null;
                    Customer             cObject       = (this.Depth > -1) ? cTable.CreateInstance(c_uObject, c_sObject, c_cObject, c_lObject, c_moObject) : null;
                    result.Add(cObject);
                } while (sqlReader.Read());
                sqlReader.Close();

                return(result);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "customloadmany", "exception"), "Customer list could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Customer", "Exception while loading (custom/many) Customer object from database. See inner exception for details.", ex);
            }
        }
示例#3
0
        protected override Customer LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             CustomerTable.GetColumnNames("[c]") +
                             (this.Depth > 0 ? "," + UserTable.GetColumnNames("[c_u]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserTypeTable.GetColumnNames("[c_u_ut]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[c_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[c_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[c_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[c_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[c_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[c_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[c_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[c_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + CountryTable.GetColumnNames("[c_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[c_c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[c_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + MobileOperatorTable.GetColumnNames("[c_mo]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[c_mo_c]") : string.Empty) +
                             " FROM [core].[Customer] AS [c] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[User] AS [c_u] ON [c].[UserID] = [c_u].[UserID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserType] AS [c_u_ut] ON [c_u].[UserTypeID] = [c_u_ut].[UserTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Service] AS [c_s] ON [c].[ServiceID] = [c_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [c_s_a] ON [c_s].[ApplicationID] = [c_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Product] AS [c_s_p] ON [c_s].[ProductID] = [c_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Merchant] AS [c_s_m] ON [c_s].[MerchantID] = [c_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceType] AS [c_s_st] ON [c_s].[ServiceTypeID] = [c_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[UserSessionType] AS [c_s_ust] ON [c_s].[UserSessionTypeID] = [c_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_s_c] ON [c_s].[FallbackCountryID] = [c_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Language] AS [c_s_l] ON [c_s].[FallbackLanguageID] = [c_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ServiceConfiguration] AS [c_s_sc] ON [c_s].[ServiceConfigurationID] = [c_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Template] AS [c_s_t] ON [c_s].[TemplateID] = [c_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Country] AS [c_c] ON [c].[CountryID] = [c_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_c_l] ON [c_c].[LanguageID] = [c_c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [c_l] ON [c].[LanguageID] = [c_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[MobileOperator] AS [c_mo] ON [c].[MobileOperatorID] = [c_mo].[MobileOperatorID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [c_mo_c] ON [c_mo].[CountryID] = [c_mo_c].[CountryID] ";
                }
                sqlCmdText += "WHERE [c].[CustomerID] = @CustomerID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@CustomerID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "loadinternal", "notfound"), "Customer could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                CustomerTable             cTable       = new CustomerTable(query);
                UserTable                 c_uTable     = (this.Depth > 0) ? new UserTable(query) : null;
                UserTypeTable             c_u_utTable  = (this.Depth > 1) ? new UserTypeTable(query) : null;
                ServiceTable              c_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          c_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              c_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             c_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          c_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      c_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              c_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             c_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable c_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             c_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                CountryTable              c_cTable     = (this.Depth > 0) ? new CountryTable(query) : null;
                LanguageTable             c_c_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                LanguageTable             c_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                MobileOperatorTable       c_moTable    = (this.Depth > 0) ? new MobileOperatorTable(query) : null;
                CountryTable              c_mo_cTable  = (this.Depth > 1) ? new CountryTable(query) : null;


                UserType             c_u_utObject  = (this.Depth > 1) ? c_u_utTable.CreateInstance() : null;
                User                 c_uObject     = (this.Depth > 0) ? c_uTable.CreateInstance(c_u_utObject) : null;
                Application          c_s_aObject   = (this.Depth > 1) ? c_s_aTable.CreateInstance() : null;
                Product              c_s_pObject   = (this.Depth > 1) ? c_s_pTable.CreateInstance() : null;
                Merchant             c_s_mObject   = (this.Depth > 1) ? c_s_mTable.CreateInstance() : null;
                ServiceType          c_s_stObject  = (this.Depth > 1) ? c_s_stTable.CreateInstance() : null;
                UserSessionType      c_s_ustObject = (this.Depth > 1) ? c_s_ustTable.CreateInstance() : null;
                Country              c_s_cObject   = (this.Depth > 1) ? c_s_cTable.CreateInstance() : null;
                Language             c_s_lObject   = (this.Depth > 1) ? c_s_lTable.CreateInstance() : null;
                ServiceConfiguration c_s_scObject  = (this.Depth > 1) ? c_s_scTable.CreateInstance() : null;
                Template             c_s_tObject   = (this.Depth > 1) ? c_s_tTable.CreateInstance() : null;
                Service              c_sObject     = (this.Depth > 0) ? c_sTable.CreateInstance(c_s_aObject, c_s_pObject, c_s_mObject, c_s_stObject, c_s_ustObject, c_s_cObject, c_s_lObject, c_s_scObject, c_s_tObject) : null;
                Language             c_c_lObject   = (this.Depth > 1) ? c_c_lTable.CreateInstance() : null;
                Country              c_cObject     = (this.Depth > 0) ? c_cTable.CreateInstance(c_c_lObject) : null;
                Language             c_lObject     = (this.Depth > 0) ? c_lTable.CreateInstance() : null;
                Country              c_mo_cObject  = (this.Depth > 1) ? c_mo_cTable.CreateInstance() : null;
                MobileOperator       c_moObject    = (this.Depth > 0) ? c_moTable.CreateInstance(c_mo_cObject) : null;
                Customer             cObject       = cTable.CreateInstance(c_uObject, c_sObject, c_cObject, c_lObject, c_moObject);
                sqlReader.Close();

                return(cObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("c", "loadinternal", "exception"), "Customer could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "Customer", "Exception while loading Customer object from database. See inner exception for details.", ex);
            }
        }
        public TranslationKey Load(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             TranslationKeyTable.GetColumnNames("[tk]") +
                             (this.Depth > 0 ? "," + TranslationKeyTable.GetColumnNames("[tk_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationKeyTable.GetColumnNames("[tk_tk_tk]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationTable.GetColumnNames("[tk_tk_t]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[tk_tk_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTable.GetColumnNames("[tk_tk_s]") : string.Empty) +
                             (this.Depth > 0 ? "," + TranslationTable.GetColumnNames("[tk_t]") : string.Empty) +
                             (this.Depth > 1 ? "," + TranslationTypeTable.GetColumnNames("[tk_t_tt]") : string.Empty) +
                             (this.Depth > 0 ? "," + LanguageTable.GetColumnNames("[tk_l]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[tk_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[tk_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[tk_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[tk_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[tk_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[tk_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[tk_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[tk_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[tk_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[tk_s_t]") : string.Empty) +
                             " FROM [core].[TranslationKey] AS [tk] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[TranslationKey] AS [tk_tk] ON [tk].[FallbackTranslationKeyID] = [tk_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[TranslationKey] AS [tk_tk_tk] ON [tk_tk].[FallbackTranslationKeyID] = [tk_tk_tk].[TranslationKeyID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Translation] AS [tk_tk_t] ON [tk_tk].[TranslationID] = [tk_tk_t].[TranslationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tk_tk_l] ON [tk_tk].[LanguageID] = [tk_tk_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [tk_tk_s] ON [tk_tk].[ServiceID] = [tk_tk_s].[ServiceID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Translation] AS [tk_t] ON [tk].[TranslationID] = [tk_t].[TranslationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[TranslationType] AS [tk_t_tt] ON [tk_t].[TranslationTypeID] = [tk_t_tt].[TranslationTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tk_l] ON [tk].[LanguageID] = [tk_l].[LanguageID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [tk_s] ON [tk].[ServiceID] = [tk_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Application] AS [tk_s_a] ON [tk_s].[ApplicationID] = [tk_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Product] AS [tk_s_p] ON [tk_s].[ProductID] = [tk_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Merchant] AS [tk_s_m] ON [tk_s].[MerchantID] = [tk_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceType] AS [tk_s_st] ON [tk_s].[ServiceTypeID] = [tk_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserSessionType] AS [tk_s_ust] ON [tk_s].[UserSessionTypeID] = [tk_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [tk_s_c] ON [tk_s].[FallbackCountryID] = [tk_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [tk_s_l] ON [tk_s].[FallbackLanguageID] = [tk_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceConfiguration] AS [tk_s_sc] ON [tk_s].[ServiceConfigurationID] = [tk_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Template] AS [tk_s_t] ON [tk_s].[TemplateID] = [tk_s_t].[TemplateID] ";
                }


                parameters.Top = 1;
                sqlCmdText     = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("tk", "customload", "notfound"), "TranslationKey could not be loaded using custom logic as it was not found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                TranslationKeyTable       tkTable       = new TranslationKeyTable(query);
                TranslationKeyTable       tk_tkTable    = (this.Depth > 0) ? new TranslationKeyTable(query) : null;
                TranslationKeyTable       tk_tk_tkTable = (this.Depth > 1) ? new TranslationKeyTable(query) : null;
                TranslationTable          tk_tk_tTable  = (this.Depth > 1) ? new TranslationTable(query) : null;
                LanguageTable             tk_tk_lTable  = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceTable              tk_tk_sTable  = (this.Depth > 1) ? new ServiceTable(query) : null;
                TranslationTable          tk_tTable     = (this.Depth > 0) ? new TranslationTable(query) : null;
                TranslationTypeTable      tk_t_ttTable  = (this.Depth > 1) ? new TranslationTypeTable(query) : null;
                LanguageTable             tk_lTable     = (this.Depth > 0) ? new LanguageTable(query) : null;
                ServiceTable              tk_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          tk_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              tk_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             tk_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          tk_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      tk_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              tk_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             tk_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable tk_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             tk_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;


                TranslationKey       tk_tk_tkObject = (this.Depth > 1) ? tk_tk_tkTable.CreateInstance() : null;
                Translation          tk_tk_tObject  = (this.Depth > 1) ? tk_tk_tTable.CreateInstance() : null;
                Language             tk_tk_lObject  = (this.Depth > 1) ? tk_tk_lTable.CreateInstance() : null;
                Service              tk_tk_sObject  = (this.Depth > 1) ? tk_tk_sTable.CreateInstance() : null;
                TranslationKey       tk_tkObject    = (this.Depth > 0) ? tk_tkTable.CreateInstance(tk_tk_tkObject, tk_tk_tObject, tk_tk_lObject, tk_tk_sObject) : null;
                TranslationType      tk_t_ttObject  = (this.Depth > 1) ? tk_t_ttTable.CreateInstance() : null;
                Translation          tk_tObject     = (this.Depth > 0) ? tk_tTable.CreateInstance(tk_t_ttObject) : null;
                Language             tk_lObject     = (this.Depth > 0) ? tk_lTable.CreateInstance() : null;
                Application          tk_s_aObject   = (this.Depth > 1) ? tk_s_aTable.CreateInstance() : null;
                Product              tk_s_pObject   = (this.Depth > 1) ? tk_s_pTable.CreateInstance() : null;
                Merchant             tk_s_mObject   = (this.Depth > 1) ? tk_s_mTable.CreateInstance() : null;
                ServiceType          tk_s_stObject  = (this.Depth > 1) ? tk_s_stTable.CreateInstance() : null;
                UserSessionType      tk_s_ustObject = (this.Depth > 1) ? tk_s_ustTable.CreateInstance() : null;
                Country              tk_s_cObject   = (this.Depth > 1) ? tk_s_cTable.CreateInstance() : null;
                Language             tk_s_lObject   = (this.Depth > 1) ? tk_s_lTable.CreateInstance() : null;
                ServiceConfiguration tk_s_scObject  = (this.Depth > 1) ? tk_s_scTable.CreateInstance() : null;
                Template             tk_s_tObject   = (this.Depth > 1) ? tk_s_tTable.CreateInstance() : null;
                Service              tk_sObject     = (this.Depth > 0) ? tk_sTable.CreateInstance(tk_s_aObject, tk_s_pObject, tk_s_mObject, tk_s_stObject, tk_s_ustObject, tk_s_cObject, tk_s_lObject, tk_s_scObject, tk_s_tObject) : null;
                TranslationKey       tkObject       = tkTable.CreateInstance(tk_tkObject, tk_tObject, tk_lObject, tk_sObject);
                sqlReader.Close();

                return(tkObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("tk", "customload", "exception"), "TranslationKey could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "TranslationKey", "Exception while loading (custom/single) TranslationKey object from database. See inner exception for details.", ex);
            }
        }
        public UserSessionType Load(ISqlConnectionInfo connection, SqlQueryParameters parameters)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            if (parameters == null)
            {
                throw new ArgumentNullException("parameters");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT {0} " +
                             UserSessionTypeTable.GetColumnNames("[ust]") +
                             " FROM [core].[UserSessionType] AS [ust] ";


                parameters.Top = 1;
                sqlCmdText     = parameters.BuildQuery(sqlCmdText);
                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                foreach (KeyValuePair <string, object> argument in parameters.Arguments)
                {
                    sqlCmd.Parameters.AddWithValue("@" + argument.Key, argument.Value);
                }

                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("ust", "customload", "notfound"), "UserSessionType could not be loaded using custom logic as it was not found.", sqlCmdText, this, connection, parameters);
                    if (this.Logger.IsDebugEnabled)
                    {
                        this.Logger.Debug(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                UserSessionTypeTable ustTable = new UserSessionTypeTable(query);


                UserSessionType ustObject = ustTable.CreateInstance();
                sqlReader.Close();

                return(ustObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("ust", "customload", "exception"), "UserSessionType could not be loaded using custom logic. See exception for details.", sqlCmdText, ex, this, connection, parameters);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "UserSessionType", "Exception while loading (custom/single) UserSessionType object from database. See inner exception for details.", ex);
            }
        }
        protected override ApplicationRouteSetMap LoadInternal(ISqlConnectionInfo connection, int id)
        {
            IDatabase database = connection.Database;

            if (database == null)
            {
                throw new ArgumentNullException("database", "Error initializing database connection.");
            }
            string sqlCmdText = string.Empty;

            try
            {
                sqlCmdText = "SELECT " +
                             ApplicationRouteSetMapTable.GetColumnNames("[arsm]") +
                             (this.Depth > 0 ? "," + ApplicationTable.GetColumnNames("[arsm_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + InstanceTable.GetColumnNames("[arsm_a_i]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTypeTable.GetColumnNames("[arsm_a_at]") : string.Empty) +
                             (this.Depth > 1 ? "," + RuntimeTypeTable.GetColumnNames("[arsm_a_rt]") : string.Empty) +
                             (this.Depth > 0 ? "," + ServiceTable.GetColumnNames("[arsm_s]") : string.Empty) +
                             (this.Depth > 1 ? "," + ApplicationTable.GetColumnNames("[arsm_s_a]") : string.Empty) +
                             (this.Depth > 1 ? "," + ProductTable.GetColumnNames("[arsm_s_p]") : string.Empty) +
                             (this.Depth > 1 ? "," + MerchantTable.GetColumnNames("[arsm_s_m]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceTypeTable.GetColumnNames("[arsm_s_st]") : string.Empty) +
                             (this.Depth > 1 ? "," + UserSessionTypeTable.GetColumnNames("[arsm_s_ust]") : string.Empty) +
                             (this.Depth > 1 ? "," + CountryTable.GetColumnNames("[arsm_s_c]") : string.Empty) +
                             (this.Depth > 1 ? "," + LanguageTable.GetColumnNames("[arsm_s_l]") : string.Empty) +
                             (this.Depth > 1 ? "," + ServiceConfigurationTable.GetColumnNames("[arsm_s_sc]") : string.Empty) +
                             (this.Depth > 1 ? "," + TemplateTable.GetColumnNames("[arsm_s_t]") : string.Empty) +
                             (this.Depth > 0 ? "," + RouteSetTable.GetColumnNames("[arsm_rs]") : string.Empty) +
                             (this.Depth > 1 ? "," + InstanceTable.GetColumnNames("[arsm_rs_i]") : string.Empty) +
                             " FROM [core].[ApplicationRouteSetMap] AS [arsm] ";
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[Application] AS [arsm_a] ON [arsm].[ApplicationID] = [arsm_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Instance] AS [arsm_a_i] ON [arsm_a].[InstanceID] = [arsm_a_i].[InstanceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[ApplicationType] AS [arsm_a_at] ON [arsm_a].[ApplicationTypeID] = [arsm_a_at].[ApplicationTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[RuntimeType] AS [arsm_a_rt] ON [arsm_a].[RuntimeTypeID] = [arsm_a_rt].[RuntimeTypeID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Service] AS [arsm_s] ON [arsm].[ServiceID] = [arsm_s].[ServiceID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Application] AS [arsm_s_a] ON [arsm_s].[ApplicationID] = [arsm_s_a].[ApplicationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Product] AS [arsm_s_p] ON [arsm_s].[ProductID] = [arsm_s_p].[ProductID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Merchant] AS [arsm_s_m] ON [arsm_s].[MerchantID] = [arsm_s_m].[MerchantID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceType] AS [arsm_s_st] ON [arsm_s].[ServiceTypeID] = [arsm_s_st].[ServiceTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[UserSessionType] AS [arsm_s_ust] ON [arsm_s].[UserSessionTypeID] = [arsm_s_ust].[UserSessionTypeID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Country] AS [arsm_s_c] ON [arsm_s].[FallbackCountryID] = [arsm_s_c].[CountryID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Language] AS [arsm_s_l] ON [arsm_s].[FallbackLanguageID] = [arsm_s_l].[LanguageID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[ServiceConfiguration] AS [arsm_s_sc] ON [arsm_s].[ServiceConfigurationID] = [arsm_s_sc].[ServiceConfigurationID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "LEFT OUTER  JOIN [core].[Template] AS [arsm_s_t] ON [arsm_s].[TemplateID] = [arsm_s_t].[TemplateID] ";
                }
                if (this.Depth > 0)
                {
                    sqlCmdText += "INNER  JOIN [core].[RouteSet] AS [arsm_rs] ON [arsm].[RouteSetID] = [arsm_rs].[RouteSetID] ";
                }
                if (this.Depth > 1)
                {
                    sqlCmdText += "INNER  JOIN [core].[Instance] AS [arsm_rs_i] ON [arsm_rs].[InstanceID] = [arsm_rs_i].[InstanceID] ";
                }
                sqlCmdText += "WHERE [arsm].[ApplicationRouteSetMapID] = @ApplicationRouteSetMapID;";

                SqlCommand sqlCmd = database.Add(sqlCmdText) as SqlCommand;
                sqlCmd.Parameters.AddWithValue("@ApplicationRouteSetMapID", id);
                SqlDataReader sqlReader = database.Add(sqlCmd) as SqlDataReader;

                if (!sqlReader.HasRows || !sqlReader.Read())
                {
                    IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("arsm", "loadinternal", "notfound"), "ApplicationRouteSetMap could not be loaded by id as it was not found.", sqlCmdText, this, connection, id);
                    if (this.Logger.IsWarnEnabled)
                    {
                        this.Logger.Warn(builder.ToString());
                    }
                    sqlReader.Close();
                    return(null);
                }

                SqlQuery query = new SqlQuery(sqlReader);

                ApplicationRouteSetMapTable arsmTable     = new ApplicationRouteSetMapTable(query);
                ApplicationTable            arsm_aTable   = (this.Depth > 0) ? new ApplicationTable(query) : null;
                InstanceTable             arsm_a_iTable   = (this.Depth > 1) ? new InstanceTable(query) : null;
                ApplicationTypeTable      arsm_a_atTable  = (this.Depth > 1) ? new ApplicationTypeTable(query) : null;
                RuntimeTypeTable          arsm_a_rtTable  = (this.Depth > 1) ? new RuntimeTypeTable(query) : null;
                ServiceTable              arsm_sTable     = (this.Depth > 0) ? new ServiceTable(query) : null;
                ApplicationTable          arsm_s_aTable   = (this.Depth > 1) ? new ApplicationTable(query) : null;
                ProductTable              arsm_s_pTable   = (this.Depth > 1) ? new ProductTable(query) : null;
                MerchantTable             arsm_s_mTable   = (this.Depth > 1) ? new MerchantTable(query) : null;
                ServiceTypeTable          arsm_s_stTable  = (this.Depth > 1) ? new ServiceTypeTable(query) : null;
                UserSessionTypeTable      arsm_s_ustTable = (this.Depth > 1) ? new UserSessionTypeTable(query) : null;
                CountryTable              arsm_s_cTable   = (this.Depth > 1) ? new CountryTable(query) : null;
                LanguageTable             arsm_s_lTable   = (this.Depth > 1) ? new LanguageTable(query) : null;
                ServiceConfigurationTable arsm_s_scTable  = (this.Depth > 1) ? new ServiceConfigurationTable(query) : null;
                TemplateTable             arsm_s_tTable   = (this.Depth > 1) ? new TemplateTable(query) : null;
                RouteSetTable             arsm_rsTable    = (this.Depth > 0) ? new RouteSetTable(query) : null;
                InstanceTable             arsm_rs_iTable  = (this.Depth > 1) ? new InstanceTable(query) : null;


                Instance               arsm_a_iObject   = (this.Depth > 1) ? arsm_a_iTable.CreateInstance() : null;
                ApplicationType        arsm_a_atObject  = (this.Depth > 1) ? arsm_a_atTable.CreateInstance() : null;
                RuntimeType            arsm_a_rtObject  = (this.Depth > 1) ? arsm_a_rtTable.CreateInstance() : null;
                Application            arsm_aObject     = (this.Depth > 0) ? arsm_aTable.CreateInstance(arsm_a_iObject, arsm_a_atObject, arsm_a_rtObject) : null;
                Application            arsm_s_aObject   = (this.Depth > 1) ? arsm_s_aTable.CreateInstance() : null;
                Product                arsm_s_pObject   = (this.Depth > 1) ? arsm_s_pTable.CreateInstance() : null;
                Merchant               arsm_s_mObject   = (this.Depth > 1) ? arsm_s_mTable.CreateInstance() : null;
                ServiceType            arsm_s_stObject  = (this.Depth > 1) ? arsm_s_stTable.CreateInstance() : null;
                UserSessionType        arsm_s_ustObject = (this.Depth > 1) ? arsm_s_ustTable.CreateInstance() : null;
                Country                arsm_s_cObject   = (this.Depth > 1) ? arsm_s_cTable.CreateInstance() : null;
                Language               arsm_s_lObject   = (this.Depth > 1) ? arsm_s_lTable.CreateInstance() : null;
                ServiceConfiguration   arsm_s_scObject  = (this.Depth > 1) ? arsm_s_scTable.CreateInstance() : null;
                Template               arsm_s_tObject   = (this.Depth > 1) ? arsm_s_tTable.CreateInstance() : null;
                Service                arsm_sObject     = (this.Depth > 0) ? arsm_sTable.CreateInstance(arsm_s_aObject, arsm_s_pObject, arsm_s_mObject, arsm_s_stObject, arsm_s_ustObject, arsm_s_cObject, arsm_s_lObject, arsm_s_scObject, arsm_s_tObject) : null;
                Instance               arsm_rs_iObject  = (this.Depth > 1) ? arsm_rs_iTable.CreateInstance() : null;
                RouteSet               arsm_rsObject    = (this.Depth > 0) ? arsm_rsTable.CreateInstance(arsm_rs_iObject) : null;
                ApplicationRouteSetMap arsmObject       = arsmTable.CreateInstance(arsm_aObject, arsm_sObject, arsm_rsObject);
                sqlReader.Close();

                return(arsmObject);
            }
            catch (Exception ex)
            {
                database.HandleException(ex);
                IMessageBuilder builder = new DbLogMessageBuilder(new LogErrorCode("arsm", "loadinternal", "exception"), "ApplicationRouteSetMap could not be loaded by id. See exception for details.", sqlCmdText, ex, this, connection, id);
                if (this.Logger.IsErrorEnabled)
                {
                    this.Logger.Error(builder.ToString(), ex);
                }
                throw new DataOperationException(DataOperation.Load, "ApplicationRouteSetMap", "Exception while loading ApplicationRouteSetMap object from database. See inner exception for details.", ex);
            }
        }