Skip to content

Instantly share code, notes, and snippets.

View kosperera's full-sized avatar
🏠
Working from home

Kosala (KP) Perera kosperera

🏠
Working from home
View GitHub Profile
@kosperera
kosperera / CategoryDataAccess.cs
Last active December 22, 2015 01:48
Mapping SQL stored procedure query results to an enumerable.
using System;
using System.Data;
using ClassicDalHelpersSample.Business.Entities;
using System.Collections.Generic;
using System.Linq;
using Snikt;
namespace Snikt.Mock
{
public sealed class CategoryDataAccess
@kosperera
kosperera / CategoryDAO.cs
Created August 31, 2013 13:05
Blogged : Yet another ORM - Code snippet 1 The old-school mapping query results to POCO.
using (IDataReader reader = command.ExecuteReader())
{
List<Category> cats = new List<Category>();
while (reader.Read())
{
int idOrdinal = reader.GetOrdinal("cid");
int nameOrdinal = reader.GetOrdinal("name");
if (!reader.IsDBNull(idOrdinal))
{
@kosperera
kosperera / WhenExecuteQuery.cs
Last active December 19, 2015 12:29
One minute unit test code for tombstoning - Code snippet 1
namespace Snikt.Specifications.DatabaseSpecs
{
[TestClass]
public class WhenExecuteQuery
{
[TestMethod]
public void ThenStrongTypedListIsReturned()
{
// Biuld
string nameOrConnectionString = "name=DefaultConnection";
@kosperera
kosperera / DocumentSpec.cs
Created August 16, 2012 13:53
Blogged: Don't ask for anything - Code snippet 3
public class Document
{
private readonly Content html;
public Document(Content content)
{
html = content;
}
}