Skip to content

Instantly share code, notes, and snippets.

@sebingel
sebingel / TSQL-to-POCO
Created February 19, 2019 16:50 — forked from joey-qc/TSQL-to-POCO
A simple TSQL script to quickly generate c# POCO classes from SQL Server tables and views. You may tweak the output as needed. Not all datatypes are represented but this should save a bunch of boilerplate coding. USAGE: Run this query against the database of your choice. The script will loop through tables, views and their respective columns. Re…
declare @tableName varchar(200)
declare @columnName varchar(200)
declare @nullable varchar(50)
declare @datatype varchar(50)
declare @maxlen int
declare @sType varchar(50)
declare @sProperty varchar(200)
DECLARE table_cursor CURSOR FOR
@sebingel
sebingel / Virtual.cs
Created February 3, 2018 22:37
Virtual in C#
using System;
namespace ConsoleApplication1
{
internal class A
{
public virtual void Foo()
{
Console.WriteLine("Foo A");
}
using (var md5 = System.Security.Cryptography.MD5.Create())
{
using (var stream = File.OpenRead(@"E:\somefile.zip"))
{
Console.WriteLine(BitConverter.ToString(md5.ComputeHash(stream)).Replace("-","‌​").ToLower());
}
}
@sebingel
sebingel / Program.cs
Created August 29, 2017 15:23
Short example of MemoryCache
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Caching;
namespace CacheTest
{
internal class Program
{
private UnitRepo _unitrepo;
@sebingel
sebingel / CalculateVectorCircleIntersection.cs
Created September 12, 2016 11:51
Calculates the intersection of a vector (given by two points) with a circle (point and radius)
using System;
using System.Drawing;
namespace ConsoleApplication1
{
internal class Program
{
private static void Main()
{
Point start = new Point(0, 0);
@sebingel
sebingel / StreamEquals.cs
Last active March 16, 2021 22:28
Compare two streams bit by bit in C#
private bool StreamEquals(Stream a, Stream b)
{
if (a == b)
{
return true;
}
if (a == null || b == null)
{
throw new ArgumentNullException(a == null ? "a" : "b");
@sebingel
sebingel / ParallelComparison.cs
Last active January 27, 2016 09:26
A small application to demonstrate different implementations of parallel computation in c# featuring await async pattern, BackgroundWorker and Task.
using System;
using System.ComponentModel;
using System.IO;
using System.Threading.Tasks;
namespace sebingel.ParallelComparision
{
internal class Program
{
static void Main()