Skip to content

Instantly share code, notes, and snippets.

View rudiv's full-sized avatar

Rudi Visser rudiv

View GitHub Profile
@rudiv
rudiv / sctest.console.cs
Last active May 10, 2018 09:11
string comparison tests
/*
Faster (probably due to no debugging attached by roslyn/linqpad), but same results overall
ICIC - 2.0579534
ToLower - 3.2817216
ToUpper - 3.2320578
ToLowerInvariant - 2.7057271
ToUpperInvariant - 2.7467674
*/
using System;
<system.net>
<mailSettings>
<smtp from="info@email.co.uk">
<network host="smtp.sendgrid.net" userName="u@d" password="p" />
</smtp>
</mailSettings>
</system.net>
@rudiv
rudiv / Program.cs
Created April 21, 2017 09:16
EF Core .Include being ignored (no logged warning as expected if EF Core detects it)
using Microsoft.EntityFrameworkCore;
using System.Linq;
namespace EFIncludeQueryable
{
public class TestEntityA
{
public int Id { get; set; }
public int TestEntityBId { get; set; }
public TestEntityB TestEntityB { get; set; }
@rudiv
rudiv / ValuesFromExtension.cs
Last active November 25, 2015 11:40
Copy values from one object to another with inclusion/exclusion list
using System.Linq;
namespace Cedita
{
public static class ModelExtensions
{
/// <summary>
/// Type-safe value copy from one object instance to another.
/// </summary>
/// <example>
@rudiv
rudiv / generate_date.sql
Created December 13, 2011 12:06
Generate Date Table SQL Server
-- This will insert X years worth of data into a Date table. All fields are INT apart from DayName and DateTime (NVARCHAR(10) and DATE respectively)
-- Update 19/12 now uses ISO Week Number
-- Define start (base) and end dates
DECLARE @basedate DATETIME = '20111101', @enddate DATETIME = '20150101';
DECLARE @days INT = 0, @date DATETIME = '20110101', @maxdays INT = DATEDIFF(dd, @basedate, @enddate);
WHILE @days <= @maxdays
BEGIN
SET @date = DATEADD(dd, @days, @basedate);