This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public partial class CustomDbContext: DbContext | |
{ | |
public override int SaveChanges() | |
{ | |
// Get all Added/Deleted/Modified entities (not Unmodified or Detached) | |
//you can get updated and deleted in same collection. I am doing so for ease of purpose | |
//getting added entries in different collection to fetch their generated ids and then log them | |
var addedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Added).ToList(); | |
var updatedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Modified).ToList(); | |
var deletedEntries = ChangeTracker.Entries().Where(e => e.State == EntityState.Deleted).ToList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Method)] | |
public class ThrottleAttribute : ActionFilterAttribute | |
{ | |
public string Name { get; set; } | |
public int Seconds { get; set; } | |
public string Message { get; set; } | |
private static MemoryCache Cache { get; } = new MemoryCache(new MemoryCacheOptions()); | |
public override void OnActionExecuting(ActionExecutingContext c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
by Martin Güther @magegu | |
just call it: | |
uploadFile(absoluteFilePath, callback); | |
*/ | |
var path = require('path'); | |
var async = require('async'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
static class Program { | |
static void Main() { | |
Console.Write("Performing some task... "); | |
using (var progress = new ProgressBar()) { | |
for (int i = 0; i <= 100; i++) { | |
progress.Report((double) i / 100); |