Пример #1
0
        public static IEnumerable <T> Get <T>(string catalog, string sql, bool isStoredProcedure, params object[] args)
        {
            try
            {
                using (Database db = new Database(GetConnectionString(catalog), ProviderName))
                {
                    return(db.QuerySP <T>(sql, args));
                }
            }
            catch (NpgsqlException ex)
            {
                if (ex.Code.StartsWith("P"))
                {
                    string errorMessage = GetDBErrorResource(ex);
                    throw new MixERPException(errorMessage, ex);
                }

                throw new MixERPException(ex.Message, ex);
            }
        }
Пример #2
0
        public static IEnumerable <T> Get <T>(string catalog, string sql, bool isStoredProcedure, params SqlParameter[] args)
        {
            try
            {
                using (Database db = new Database(GetConnectionString(catalog), ProviderName))
                {
                    if (isStoredProcedure)
                    {
                        return(db.QuerySP <T>(sql, args));
                    }
                    return(db.Query <T>(sql, args));
                }
            }
            catch (SqlException ex)
            {
                if (ex.Message.StartsWith("P"))
                {
                    throw new MixERPException(ex.Message, ex);
                }

                throw new MixERPException(ex.Message, ex);
            }
        }