Exemple #1
0
 public string GetRoutineDefinition(Routine routine)
 {
     using (var sqlConnection = new NpgsqlConnection(connectionString))
     {
         using (var cmd = new NpgsqlCommand(@"SELECT prosrc FROM pg_proc where proname =  @id
     ", sqlConnection))
         {
             sqlConnection.Open();
             cmd.CommandType = CommandType.Text;
             cmd.Parameters.AddWithValue("@id", routine.Name);
             using (var reader = cmd.ExecuteReader())
             {
                 if (reader.Read())
                 {
                     var result =reader.IsDBNull(0) ? null : reader.GetString(0);
                     return result;
                 }
                 throw new Exception("Could not find "+routine.Name);
             }
         }
     }
 }
Exemple #2
0
 public string GetRoutineDefinition(Routine routine)
 {
     using (var sqlConnection = new SqlConnection(connectionString))
     {
         using (var cmd = new SqlCommand(@"select definition from sys.sql_modules
     where object_id=object_id(@id)
     ", sqlConnection))
         {
             sqlConnection.Open();
             cmd.CommandType = CommandType.Text;
             cmd.Parameters.Add("@id", SqlDbType.NVarChar).Value = routine.Name;
             using (var reader = cmd.ExecuteReader())
             {
                 if (reader.Read())
                 {
                     return reader.GetString(0);
                 }
                 return null;
             }
         }
     }
 }