Instantly share code, notes, and snippets.

View gist:d3a9307f2254edf18ea7eec2fceddc5e
public class Program {
public static void Main(){
int i = 2 + 2;
System.Console.WriteLine("Hello World:" + i);
}
}
View test1.schema
CREATE Table
View test-hap.cs
// From File
var doc = new HtmlDocument();
doc.Load(filePath);
// From String
var doc = new HtmlDocument();
doc.LoadHtml(html);
// From Web
var url = "http://html-agility-pack.net/";
View entity-framework-extensions-docs-how-soft-delete-example-1.cs
using (var ctx = new CurrentContext())
{
var lastLogin = DateTime.Now.AddYears(-2);
var list = ctx.Customers.Where(x => x.LastLogin < lastLogin).ToList();
ctx.Customers.RemoveRange(list);
// HOW to automatically handle soft delete?
ctx.BulkSaveChanges();
}
View entity-framework-extensions-docs-how-custom-key-example-1.cs
// Single Key
ctx.BulkUpdate(customers, operation => operation.ColumnPrimaryKeyExpression =
customer => customer.Code);
// Surrogate Key (with anonymous type)
ctx.BulkUpdate(customers, operation => operation.ColumnPrimaryKeyExpression =
customer => new { customer.Code1, customer.Code2, customer.Code3 });
View entity-framework-extensions-docs-how-custom-column-example-1.cs
// DON'T add the key if auto-generated
ctx.BulkInsert(customers, operation => operation.ColumnInputExpression =
customer => new {customer.Name, customer.Email});
// ALWAYS add the key
ctx.BulkUpdate(customers, operation => operation.ColumnInputExpression =
customer => new { customer.ID, customer.Name, customer.Email });
// ALWAYS add the key
ctx.BulkMerge(customers, operation => operation.ColumnInputExpression =
View entity-framework-extensions-docs-how-benchmark-example-1.cs
public Benchmark()
{
// BENCHMARK using Stopwatch
var clock1 = new Stopwatch();
var clock2 = new Stopwatch();
var nbRecord = 1000;
var nbTry = 5;
var list = GenerateData(nbRecord);