Skip to content

Instantly share code, notes, and snippets.

Wullems Bart wullemsb

Block or report user

Report or block wullemsb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View CheckPendingMigrations.cs
if (!Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT").Equals("local", StringComparison.OrdinalIgnoreCase))
var serviceProvider = services.BuildServiceProvider();
using (var ctx = serviceProvider.GetService<SampleContext>())
var pendingMigrations = ctx.Database.GetPendingMigrations().ToList();
if (pendingMigrations.Any())
throw new Exception(
$@"Please contact the administrator. The following database migrations are pending:
View GetProductsDiscontinued.cs
public ActionResult<IEnumerable<Product>> Get()
_logger.LogInformation("Getting all products");
using (var uow = _unitOfWorkFactory.Create())
var products = _repository
.Where(p=> p.Discontinued=false);
View GetProducts.cs
// GET api/products
public ActionResult<IEnumerable<Product>> Get()
_logger.LogInformation("Getting all products");
using (var uow = _unitOfWorkFactory.Create())
var products = _repository.GetProducts();
return products;
View TaggedQueries.cs
await dataContext.Products
View web.config
<cookieHandler requireSsl="true" name="AppNameAuth" />
<wsFederation passiveRedirectEnabled="false" issuer="" realm="https://localhost/AppName/FederationResult/" requireHttps="true" />
View SampleDbContext.cs
public class SampleDbContext : DbContext
public SampleDbContext(DbContextOptions options)
: base(options)
{ }
protected override void OnModelCreating(ModelBuilder builder)
View StringExtensions.cs
public static class StringExtensions
public static string ToSnakeCase(this string input)
var startUnderscores = Regex.Match(input, @"^_+");
return startUnderscores + Regex.Replace(input, @"([a-z0-9])([A-Z])", "$1_$2").ToLower();
View killconnections.sql
pg_terminate_backend (
pg_stat_activity.datname = 'sampledb';
View ModelBuilder.cs
.Id(e=> e.Id)
.Property(e => e.Strings)
v => string.Join(',', v),
v => v.Split(',', StringSplitOptions.RemoveEmptyEntries));
You can’t perform that action at this time.