Skip to content

Instantly share code, notes, and snippets.

View janhebnes's full-sized avatar

Jan Hebnes janhebnes

View GitHub Profile
@janhebnes
janhebnes / BatchCommands.cs
Last active September 15, 2016 09:00
Batching Commands for SQL and Optimizing network round trips. http://blog.jan.hebnes.dk/2016/09/batching-commands-for-sql-and_15.html
/// <summary>
/// Handle Database operations
/// </summary>
/// <remarks>The default network packet size is 4,096 bytes. More information at http://technet.microsoft.com/en-us/library/ms177437.aspx </remarks>
public class BatchCommands
{
private StringBuilder _query = new StringBuilder();
private int _bufferLength = 0;
public static string ConnectionString
{
@janhebnes
janhebnes / Common.targets
Last active July 28, 2017 19:22
MSBuild - Just include in project file. Detects on project folder level latest TFS or Git Revision using tf.exe history or git rev-list count HEAD for a revision number and git log -1 pretty=format:%h . for hash and replaces the Revision in AssemblyVersion and AssemblyFileVersion for AssemblyInfo.cs prior to building the project with CustomTasks…
<!--
***********************************************************************************************
Embed in csproj with import and the build events are hooked up automatically
<Import Project="..\..\..\Common.targets" Condition="Exists('..\..\..\Common.targets')" />
PreBuild - Handling revision on build so the source control revision number of the project folder is embeded in the last numeric of the projects AssemblyInfoVersion and AssemblyInfoFileVersion
PostBuild - Sets revision to 0 and reverts the file with a copy upon finishing for not introducing change on version control for the assemblyInfo.cs
In debug mode the revision detection is disabled, and notification is shown instead.