Skip to content

Instantly share code, notes, and snippets.

@DavidBoike
DavidBoike / PrepareFailTest.csproj
Last active June 17, 2021 19:06
Reproduction for Microsoft.Data.SqlClient deadlocking issue https://github.com/dotnet/SqlClient/issues/1124
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net472</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient" Version="2.1.3" />
<Reference Include="System.Transactions" />
@DavidBoike
DavidBoike / MultipleSqlSagas.cs
Created March 29, 2018 18:35
Example showing event handled by multiple sagas at the same time
using System;
using System.Data.SqlClient;
using System.Threading.Tasks;
using NServiceBus;
using NServiceBus.Persistence.Sql;
namespace MultiSqlSagas
{
class Program
{
#Basic Setup
Install-WindowsUpdate -AcceptEula
Update-ExecutionPolicy Unrestricted
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
# Windows Features
choco install IIS-WebServerRole -source windowsfeatures
choco install IIS-HttpCompressionDynamic -source windowsfeatures
choco install IIS-ManagementScriptingTools -source windowsfeatures
@DavidBoike
DavidBoike / App.config
Last active August 29, 2015 14:01
Error Notifier for ServiceControl
<MessageEndpointMappings>
<add Messages="ServiceControl.Contracts" Endpoint="Particular.ServiceControl" />
</MessageEndpointMappings>
@DavidBoike
DavidBoike / boxstarter.txt
Last active September 7, 2016 20:39
David's Boxstarter Script
#Basic Setup
Install-WindowsUpdate -AcceptEula
Update-ExecutionPolicy Unrestricted
Set-ExplorerOptions -showHiddenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions
Enable-RemoteDesktop
# Windows Features
choco install Microsoft-Hyper-V-All -source windowsFeatures
choco install IIS-WebServerRole -source windowsfeatures
choco install IIS-HttpCompressionDynamic -source windowsfeatures
@DavidBoike
DavidBoike / EndpointConfig.cs
Created March 30, 2014 20:18
Configuration to enable NServiceBus.Rfc1149 transport.
public class EndpointConfig : IConfigureThisEndpoint, AsA_Server, IWantCustomInitialization
{
public void Init()
{
Configure.With()
.UseTransport<Rfc1149>();
}
}
@DavidBoike
DavidBoike / ExampleController.cs
Last active March 4, 2021 01:35
Helps with custom "deep routes" within ASP.NET MVC of the form "parent/{parentId}/child/{childId}/deeperChild/{id}" by examining route data and inserting the values into properties or fields that match within the controller.
[RoutePrefix("Parent/{parentId:int}/ChildThings")]
[InjectRouteData]
public class ExampleController : Controller
{
private int _parentId;
private ParentThing parentThing;
// Value is injected from the route by the InjectRouteDataAttribute and sets parentThing.
protected int parentId
{
@DavidBoike
DavidBoike / CasingTest.cs
Created May 16, 2012 20:50
RavenDB Unit Test - Saving changes to document should not alter doc id casing
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Raven.Client;
using Raven.Client.Embedded;
using Xunit;
using System.Text.RegularExpressions;
namespace RavenCasingTest
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Castle.DynamicProxy;
using System.Web.UI;
namespace DynamicProxyTest
{
class Program
<?xml version="1.0" encoding="utf-16"?>
<ShowPlanXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="1.1" Build="10.0.2531.0" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan">
<BatchSequence>
<Batch>
<Statements>
<StmtSimple StatementCompId="6" StatementEstRows="1860310" StatementId="2" StatementOptmLevel="FULL" StatementSubTreeCost="1214.54" StatementText="MERGE TargetTable as T&#xD;&#xA;USING @tSource S&#xD;&#xA; on S.Key1 = T.Key1 and S.Key2 = T.Key2&#xD;&#xA; &#xD;&#xA;WHEN MATCHED AND T.Data1 &lt;&gt; S.Data1 OR T.Data2 &lt;&gt; S.Data2 OR T.Data3 &lt;&gt; S.Data3 THEN&#xD;&#xA; UPDATE SET&#xD;&#xA; T.Data1 = S.Data1,&#xD;&#xA; T.Data2 = S.Data2,&#xD;&#xA; T.Data3 = S.Data3&#xD;&#xA;&#xD;&#xA;WHEN NOT MATCHED BY TARGET THEN&#xD;&#xA; INSERT (Key1, Key2, Data1, Data2, Data3)&#xD;&#xA; VALUES (Key1, Key2, Data1, Data2, Data3)&#xD;&#xA;&#xD;&#xA;WHEN NOT MATCHED BY SOURCE AND T.Key1 = @id THEN&#xD;&#xA; DELETE&#xD;&#xA;&#x