Skip to content

Instantly share code, notes, and snippets.

@NickCraver
Last active February 20, 2016 01:09
Show Gist options
  • Save NickCraver/d4c8f8f00eb948a97763 to your computer and use it in GitHub Desktop.
Save NickCraver/d4c8f8f00eb948a97763 to your computer and use it in GitHub Desktop.
How to be a jerk using SQL and Dapper
var tb = AppDomain.CurrentDomain
.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess.Run)
.DefineDynamicModule("DM")
.DefineType("Type with spaces in the name", TypeAttributes.Public);
tb.DefineField("Is💩Post", typeof(bool), FieldAttributes.Public);
var spt = tb.CreateType();
this.Connection.QueryFirstOrDefault(spt, "Select 1 as [Is💩Post]").Dump();
<Query Kind="Statements">
<Connection>
<ID>c4ca2c63-939c-44ca-a154-2d7e1f9db2a7</ID>
<Persist>true</Persist>
<Server>.</Server>
<Database>tempdb</Database>
<ShowServer>true</ShowServer>
</Connection>
<NuGetReference Prerelease="true">Dapper</NuGetReference>
<Namespace>Dapper</Namespace>
<Namespace>System.Reflection.Emit</Namespace>
</Query>
var tb = AppDomain.CurrentDomain
.DefineDynamicAssembly(new AssemblyName("Test"), AssemblyBuilderAccess.Run)
.DefineDynamicModule("DM")
.DefineType("Type with spaces in the name", TypeAttributes.Public);
tb.DefineField("Is💩Post", typeof(bool), FieldAttributes.Public);
var spt = tb.CreateType();
this.Connection.QueryFirstOrDefault(spt, "Select 1 as [Is💩Post]").Dump();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment