I hereby claim:
- I am NickCraver on github.
- I am nickcraver (https://keybase.io/nickcraver) on keybase.
- I have a public key whose fingerprint is 9854 D2C3 4BEF 984F 7310 DC97 A163 F138 E6C1 87DF
To claim this, I am signing this object:
<?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.2" Build="11.0.5343.0" xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan"> | |
<BatchSequence> | |
<Batch> | |
<Statements> | |
<StmtSimple StatementCompId="1" StatementEstRows="1" StatementId="1" StatementOptmLevel="FULL" StatementSubTreeCost="162.511" StatementText="Select Count(*)
 From InterfaceTraffic" StatementType="SELECT" QueryHash="0x9DA8413D2DA45AE8" QueryPlanHash="0xDCB2FBECB646294A" RetrievedFromCache="true"> | |
<StatementSetOptions ANSI_NULLS="true" ANSI_PADDING="true" ANSI_WARNINGS="true" ARITHABORT="true" CONCAT_NULL_YIELDS_NULL="true" NUMERIC_ROUNDABORT="false" QUOTED_IDENTIFIER="true" /> | |
<QueryPlan DegreeOfParallelism="24" MemoryGrant="51280" CachedPlanSize="512" CompileTime="766" CompileCPU="765" CompileMemory="15912"> | |
<ThreadStat Branches="2" UsedThreads="48"> | |
< |
Declare @MaxResultCount int = 50; | |
SELECT AvgCPU, AvgDuration, AvgReads, AvgCPUPerMinute, | |
TotalCPU, TotalDuration, TotalReads, | |
PercentCPU, PercentDuration, PercentReads, PercentExecutions, | |
ExecutionCount, | |
ExecutionsPerMinute, | |
PlanCreationTime, LastExecutionTime, | |
SUBSTRING(st.text, | |
(StatementStartOffset / 2) + 1, |
void Main() { } | |
public class DbColumn | |
{ | |
private readonly Dictionary<string, object> _customValues = new Dictionary<string, object>(); | |
public virtual bool AllowDBNull { get; set; } | |
public virtual string BaseCatalogName { get; set; } | |
public virtual string BaseColumnName { get; set; } | |
public virtual string BaseSchemaName { get; set; } | |
public virtual string BaseServerName { get; set; } |
I hereby claim:
To claim this, I am signing this object:
void Main() | |
{ | |
var c = new DbColumn() { ColumnName = "test" }; | |
var sw = Stopwatch.StartNew(); | |
for (var i = 0; i < 10000000; i++) | |
{ | |
var test = c["ColumnName"]; | |
} | |
sw.Stop(); | |
sw.ElapsedMilliseconds.Dump(); |
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(); |
// Here's a normal query as you'd expect | |
db.QuerySingleOrDefault<PostCacheEntry>(@"SELECT | |
(Select Count(*) From Posts Where PostTypeId = @Question And DeletionDate Is Null) TotalQuestions, | |
(Select Count(*) From Posts Where PostTypeId = @Question And IsNull(IsAnswered, 0) = 0 And AcceptedAnswerId Is Null And ClosedDate Is Null And DeletionDate Is Null) TotalUnanswered, | |
(Select Count(*) From Posts Where PostTypeId = @Question And AcceptedAnswerId Is Not NulL And DeletionDate Is Null) TotalAccepted, | |
(Select Count(*) From Posts Where PostTypeId = @Answer And DeletionDate Is Null) TotalAnswers", | |
new { PostTypeId.Question, PostTypeId.Answer }); | |
// In this case though, PostTypeId.Question and PostTypeId.Answer are values that never change. | |
// In this case they're constants, but this same trick works for enums. |
void Main() | |
{ | |
var child = new Child(); | |
child.Prop = false; | |
child.Prop.Dump(); | |
var propertyInfo = typeof(Child).GetProperty(nameof(Child.Prop)); | |
propertyInfo.GetGetMethod().Dump(); | |
propertyInfo.GetSetMethod().Dump(); | |
} | |
public class Base |
void Main() | |
{ | |
"99999999".Dump(); | |
Int32ToBase64(99999999).Dump(); | |
} | |
private static readonly char[] EqualsChar = { '=' }; | |
private static string Int32ToBase64(int i) | |
{ | |
try |
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.5" Build="13.0.1601.5"> | |
<BatchSequence> | |
<Batch> | |
<Statements> | |
<StmtSimple StatementText="CREATE function sys.fn_hadr_is_same_replica(
	@lag_id uniqueidentifier,
 @lag_replica_id uniqueidentifier,
	@ag_replica_id uniqueidentifier)
returns bit
as
begin
 declare @ag_id uniqueidentifier
	 declare @local_replica_id uniqueidentifier
	 declare @ret bit
	 
 SELECT @ag_id = group_id 
 FROM sys.fn_hadr_distributed_ag_replica(@lag_id, @lag_replica_id)" StatementId="1" StatementCompId="3" StatementType="SELECT" RetrievedFromCache="true" StatementSubTreeCost="1.157e-006" StatementEstRows="1" SecurityPolicyApplied="false" StatementOptmLevel="FULL" QueryHash="0x48E1F82013EEA15A" QueryPlanHash="0x3443401473380A77" StatementOptmEarlyAbortReason="GoodEnoughPlanF |