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 class With | |
{ | |
const int SqlDeadlockErrorNumber = 1205; | |
const int RetryLimit = 10; | |
public static T DeadlockRetry<T>(Func<T> thingToTry) | |
{ | |
var lastError = new Exception("Unknown state"); | |
for (int i = 0; i < RetryLimit; i++) | |
{ | |
try |
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.Collections.Generic; | |
using System.Linq; | |
public static class EnumerableExtensions | |
{ | |
public static IEnumerable<T> DistinctOn<T, TS>(this IEnumerable<T> src, Func<T, TS> selector) | |
{ | |
var ge = new GeneralEquality<T,TS>(selector); | |
return src.Distinct(ge); |
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
// A repository. | |
public interface IPurchaseOrderRepository | |
{ | |
PurchaseOrder Get(string id); | |
// The commit method would likely be moved to a Unit of Work managed by infrastructure. | |
void Commit(); | |
} | |
// A marker interface for a domain event. | |
public interface IDomainEvent { } |
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.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Security.Principal; | |
namespace GhettoPermissions | |
{ | |
class Program | |
{ |
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.Collections.Generic; | |
using System.Data.Entity; | |
using System.Data.Entity.Infrastructure; | |
using System.Data.Entity.Migrations; | |
using System.Linq; | |
using System.Text.RegularExpressions; | |
/// <summary> | |
/// Provides advanced migrations by providing a seeding platform for each migration. |
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Database.SetInitializer(new DropCreateDatabaseAlways<PeopleContext>()); | |
var context = new PeopleContext(); | |
context.Database.Log = Console.WriteLine; // so we can inspect SQL statements | |
AddOnePerson(context); |
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 static class DataContextExtensions | |
{ | |
/// <summary> | |
/// Map private collection property | |
/// </summary> | |
/// <typeparam name="T">Entity type</typeparam> | |
/// <typeparam name="R">Collection entity</typeparam> | |
/// <param name="propertyName">property name</param> | |
public static ManyNavigationPropertyConfiguration<T, R> HasMany<T, R>(this EntityTypeConfiguration<T> mapper, string propertyName) | |
where T : class |
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.Web.Http; | |
using Autofac; | |
using Microsoft.WindowsAzure.Mobile.Service; | |
using Microsoft.WindowsAzure.Mobile.Service.Config; | |
using Owin; | |
namespace henrikntest09Service | |
{ | |
public static class WebApiConfig | |
{ |
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
Dropping Database. | |
Rebuild Database with latest Schema. | |
Load basic test environment data. | |
Loading basic account data. | |
Opening outer Transaction scope | |
Executing test 1. | |
Executing test 2. | |
Roll back transaction scope. |
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.Collections.Generic; | |
using System.ComponentModel.DataAnnotations.Schema; | |
using System.Data.Entity; | |
using System.Data.Entity.ModelConfiguration.Conventions; | |
using System.Linq; | |
using System.Reflection; | |
namespace ConsoleApplication1.Model | |
{ |