Skip to content

Instantly share code, notes, and snippets.

@jfbueno
Last active May 3, 2016 18:17
Show Gist options
  • Save jfbueno/740f078eb85fb79b525b4cc07dc08423 to your computer and use it in GitHub Desktop.
Save jfbueno/740f078eb85fb79b525b4cc07dc08423 to your computer and use it in GitHub Desktop.
public static class DatabaseLogger
{
public static void Log(string query)
{
var words = query.Split(' ');
if (words.FirstOrDefault()?.ToUpper() == "UPDATE")
{
//aqui salva o log de update
}
}
}
//Lá no contexto
public DatabaseContext : DbContext
{
public DatabaseContext() : base("Connstring")
{
Database.Log = (message) => DatabaseLogger.Log(message);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment