Skip to content

Instantly share code, notes, and snippets.

{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"description": "Amazon CloudWatch Agent JSON Schema",
"properties": {
"agent": {
"$ref": "#/definitions/agentDefinition"
},
"metrics": {
"$ref": "#/definitions/metricsDefinition"
@elvishfiend
elvishfiend / SapDataTableToDotNetDataTable.cs
Created April 29, 2019 07:26
Converts a SAP Business One DataTable (as XML) to a System.Data.DataTable
public DataTable SapDataTableToDotNetDataTable(string pathToXmlFile)
{
var DT = new DataTable();
var XMLstream = new System.IO.FileStream(pathToXmlFile, FileMode.Open);
var XDoc = System.Xml.Linq.XDocument.Load(XMLstream);
var Columns = XDoc.Element("DataTable").Element("Columns").Elements("Column");
@elvishfiend
elvishfiend / indexviewtest.sql
Created February 15, 2018 05:23
Indexed View ft. Count_Big - testing Index Substitution on Counts
IF (OBJECT_ID('Count_Test_View') IS NOT NULL)
DROP VIEW Count_Test_View
IF (OBJECT_ID('Count_Test') IS NOT NULL)
DROP TABLE Count_Test
CREATE TABLE Count_Test
(
Id int Identity(1,1) PRIMARY KEY NOT NULL,
value int
@elvishfiend
elvishfiend / ExampleUsage.cs
Created July 27, 2017 10:58 — forked from NickCraver/ExampleUsage.cs
Code to mark a SQL string before it's passed to Dapper.
public static List<T> Query<T>(this DataContext db, string sql, object param = null, int? commandTimeout = null, IDbTransaction transaction = null, [CallerFilePath]string fromFile = null, [CallerLineNumber]int onLine = 0, string comment = null)
{
using (db.Connection.EnsureOpen())
{
try
{
return db.Connection.Query<T>(MarkSqlString(sql, fromFile, onLine, comment), param, transaction ?? db.Transaction, true, commandTimeout).AsDapperList();
}
catch (SqlException ex) when (ex.Is(SqlErrorCode.DatabaseReadOnly_3906))
{