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
-- See http://technet.microsoft.com/en-us/library/ms188783.aspx | |
-- "For UNIQUE indexes, only the selected rows must have unique index values." | |
CREATE TABLE foo (pk int PRIMARY KEY IDENTITY, x int NULL); | |
GO | |
CREATE UNIQUE INDEX U_Foo_x ON foo (x) WHERE x is not null; | |
GO | |
INSERT INTO foo (x) VALUES (1); |
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
WindsorContainer container; | |
void Main() | |
{ | |
CompositionRoot (); | |
Test (); | |
} | |
void Test () | |
{ |
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
abstract class ValueTypeHandler<T> : SqlMapper.ITypeHandler where T : struct | |
{ | |
public abstract T Parse (object value); | |
public abstract void SetValue(IDbDataParameter parameter, T value); | |
object SqlMapper.ITypeHandler.Parse (Type destinationType, object value) | |
{ | |
if (value == null) { | |
return null; | |
} else if (value is DBNull) { |
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
void Main() | |
{ | |
// SqlMapper.AddTypeHandler<T>(TypeHandler<T>) does not register the nullable version | |
// Instead, use the SqlMapper.AddTypeHandler(Type, ITypeHandler) overload | |
SqlMapper.AddTypeHandler(typeof(LocalDate), LocalDateHandler.Default); | |
// Without this line a NullReferenceException is thrown | |
SqlMapper.AddTypeHandler(typeof(LocalDate?), LocalDateHandler.Default); | |
using (var db = new SqlConnection (@"Data Source=.;Initial Catalog=tempdb;Integrated Security=True")) { |
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
#define NONEST | |
RebusBus bus = new RebusBus (); | |
WindsorContainer container; | |
void Main() | |
{ | |
BuildContainer (); | |
Subscribe (bus, container.Kernel); | |
bus.subscribed.Dump (); |
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 abstract class SimpleModelBinderBase : IModelBinder | |
{ | |
public object BindModel (ControllerContext controllerContext, ModelBindingContext bindingContext) | |
{ | |
var key = bindingContext.ModelName; | |
var result = bindingContext.ValueProvider.GetValue (key); | |
if (result == null) { | |
return null; | |
} |
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
void Main() | |
{ | |
SingleToInt32Bits (5.0f).Dump (); | |
Int32BitsToSingle (1084227584).Dump (); | |
} | |
public static int SingleToInt32Bits (float f) | |
{ | |
return new FloatConvert { F = f }.I; | |
} |
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
DECLARE @mark CHAR(32) = replace(newid(), '-', ''); | |
DECLARE @trans INT = @@TRANCOUNT; | |
IF @trans = 0 | |
BEGIN TRANSACTION @mark; | |
ELSE | |
SAVE TRANSACTION @mark; | |
BEGIN TRY | |
-- do work here |
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
static XNamespace ns = "http://schemas.microsoft.com/developer/msbuild/2003"; | |
static XName ItemGroup = ns + "ItemGroup"; | |
static XName Reference = ns + "Reference"; | |
static XName ProjectReference = ns + "ProjectReference"; | |
static XName Condition = "Condition"; | |
static XName Include = "Include"; | |
void Main(string[] args) | |
{ | |
if (args.Length != 1) { |
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
/* | |
Due to boostrap's high specificity on td styles | |
I cannot see a shorter method to override this. | |
*/ | |
.table.vert-align-mid > thead > tr > td, | |
.table.vert-align-mid > thead > tr > th, | |
.table.vert-align-mid > tbody > tr > td, | |
.table.vert-align-mid > tbody > tr > th, | |
.table.vert-align-mid > tfoot > tr > td, |
OlderNewer