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
using System; | |
using System.Data.SqlClient; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Runtime.InteropServices; | |
namespace Utilities | |
{ | |
/// <summary> |
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
########################################## | |
### Registers Windows Scheduled Tasks ### | |
########################################## | |
<############################################################################################################### | |
Notes: | |
- This example was from a working solution I created where this script was run as a post-deploy step for a | |
console application that served as the entry point for multiple scheduled tasks that could be executed | |
by supplying the task name. |
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
/* Oracle PL/SQL example of a query with an optional date range */ | |
SET SERVEROUTPUT ON; | |
DECLARE | |
StartDate DATE := NULL; | |
EndDate DATE := NULL; | |
--StartDate DATE := TO_DATE ('01/01/2017', 'mm/dd/yyyy'); | |
--EndDate DATE := TO_DATE ('02/01/2017', 'mm/dd/yyyy'); | |
RecordCount NUMBER; | |
BEGIN | |
SELECT COUNT(*) |
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
internal void ValidateOrderByClause(string orderBy, string[] supportedOrderByFields) | |
{ | |
if (!string.IsNullOrWhiteSpace(orderBy)) | |
{ | |
var orderBys = orderBy.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); | |
foreach (var orderByClause in orderBys) | |
{ | |
var orderByClauseParts = orderByClause.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries); | |
var orderByClauseField = orderByClauseParts[0]; |
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
using System; | |
using System.Configuration; | |
using System.Reflection; | |
namespace Utilities.Options | |
{ | |
/// <summary> | |
/// Uses <see cref="ConfigurationManager"/> to populate options. | |
/// Finds setting names/keys by <see cref="OptionNameAttribute"/>, {PropertyName}, or {ClassName}.{PropertyName}. | |
/// </summary> |
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
using System; | |
namespace Utilities.Extensions | |
{ | |
public static class ConsoleColorExtensions | |
{ | |
/// <summary> | |
/// Writes the specified string value, followed by the current line terminator, to the standard output stream. | |
/// </summary> | |
/// <example> |
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
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using System.Data.Entity.Migrations; | |
using System.Data.Entity.Migrations.Design; | |
using System.Diagnostics; | |
using System.Linq; | |
namespace YabbaDabbaDoo | |
{ | |
[TestClass] | |
public class EntityFrameworkMigrationTests |
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
!*.csproj.user;!UpgradeLog.htm;!*.vspscc;!packages\;!bin\;!bld\;!ClientBin\;!Debug\;!obj\;!AppPackages\;!Release\;!TestResults\;!*.*~!*.appx!*.appxrecipe;!*.cache!*.cer!*.dbmdl!*.dll!*.docstates!*.docstates.suo;!*.err!*.exe!*.ilk!*.ipch!*.lastbuildstate!*.lce!*.ldf!*.lib!*.log!*.mdf!*.msscci!*.ncb!*.obj!*.opensdf!*.pch!*.pdb!*.pri!*.res!*.resources!*.sdf!*.suo!*.swp!*.temp!*.tfOrig*!*.tlog!*.tmp!*.trx!*.user!*.unsuccessfulbuild!*.v11.suo!*.vcxproj.user!*.vsix!*.vsmdi!*.vspscc!*.vssettings!*.vssscc!*.wrn!*.xap;!.metadata\ |
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
CREATE TABLE TableName | |
( | |
TableNameId INT NOT NULL IDENTITY(1,1), | |
/* Other columns */ | |
CreatedDate DATETIME2 NOT NULL CONSTRAINT [DF_TableName_CreatedDate] DEFAULT (GETDATE()), | |
CreatedBy VARCHAR(100) NOT NULL CONSTRAINT [DF_TableName_CreatedBy] DEFAULT (SUSER_SNAME()), | |
CreatedByHostName VARCHAR(100) NOT NULL CONSTRAINT [DF_TableName_CreatedByHostName] DEFAULT (HOST_NAME()), | |
ModifiedDate DATETIME2 NOT NULL CONSTRAINT [DF_TableName_ModifiedDate] DEFAULT (GETDATE()), | |
ModifiedBy VARCHAR(100) NOT NULL CONSTRAINT [DF_TableName_ModifiedBy] DEFAULT (SUSER_SNAME()), | |
ModifiedByHostName VARCHAR(100) NOT NULL CONSTRAINT [DF_TableName_ModifiedByHostName] DEFAULT (HOST_NAME()) |
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
/// <summary> | |
/// Insert list into a database table using Oracle array binding (a type of bulk insert). | |
/// </summary> | |
/// <typeparam name="T">Type of data in list.</typeparam> | |
/// <param name="listOfData">List to insert.</param> | |
/// <param name="tableName">Table name.</param> | |
/// <returns>Rows affected.</returns> | |
public int Insert<T>(List<T> listOfData, string tableName) where T : class, new() | |
{ | |
try |