Skip to content

Instantly share code, notes, and snippets.

View tawman's full-sized avatar

Todd A. Wood tawman

View GitHub Profile
@tawman
tawman / IToddWood.cs
Created January 21, 2012 18:44
Implement IToddWood Blog - http://www.wooodcp.com
using System;
using System.Collections.Generic;
namespace WoodConsultingPractice
{
public interface IToddWood
{
IEnumerable<Result> Work<T>(T challenge);
IEnumerable<Memory> Life(Action action);
Post Blog<T>(Result knowledge, Memory experience, T content);
@tawman
tawman / LinqExamples.cs
Created January 26, 2012 14:43
Stackoverflow Question: Select list of x via list of y
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
namespace StackOverflowQuestionsTests
{
[TestFixture]
class LinqExamples
@tawman
tawman / PetaPocoHierarchyCreateTable.sql
Created January 29, 2012 22:09
PetaPocoHierarchy Organization Table SQL CREATE Script
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Organization](
[Id] [uniqueidentifier] NOT NULL,
[ParentId] [uniqueidentifier] NULL,
[OrganizationCode] [nvarchar](10) NOT NULL,
@tawman
tawman / Organization.cs
Created January 29, 2012 22:32
PetaPocoHierarchy Organization POCO
using System;
using System.Linq;
using System.Collections.Generic;
using PetaPoco;
namespace PetaPocoHierarchy.Models
{
public class Organization
{
public Guid Id { get; set; }
@tawman
tawman / OrganizationRepository.cs
Created February 2, 2012 02:52
PetaPocoHierarchy Organization Repository
using System.Collections.Generic;
using PetaPocoHierarchy.Models;
namespace PetaPocoHierarchy.Services
{
public class OrganizationRepository : Repository, IOrganizationRepository
{
public IEnumerable<Organization> GetAll()
{
// SELECT a row of data containing an Organization and Parent Organization
@tawman
tawman / OrganizationParentRelator.cs
Created February 2, 2012 02:53
PetaPocoHierarchy Multi-Poco Mapping Helper
using PetaPocoHierarchy.Models;
namespace PetaPocoHierarchy.Services
{
/// <summary>
/// Set Organization Parent in the Organization Hierarchy
/// </summary>
/// <remarks>
/// Based on logic for mapping demo: http://www.toptensoftware.com/Articles/115/PetaPoco-Mapping-One-to-Many-and-Many-to-One-Relationships
/// </remarks>
@tawman
tawman / DynamicReportSource.cs
Created February 9, 2012 23:00
DoodleReport Dynamic Report Source Extensions ToReportSource() for IEnumerable<dynamic>
using System.Collections;
using System.Collections.Generic;
using System.Linq;
namespace DoddleReport
{
public static class DynamicReportSourceExtensions
{
public static IReportSource ToReportSource(this IEnumerable<dynamic> source)
{
@tawman
tawman / DynamicReportSource.cs
Created February 10, 2012 17:43
DynamicReportSource Null Object Reference Fix
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using DoddleReport;
namespace Hasc.Web.Helpers
{
public static class DynamicReportSourceExtensions
{
public static IReportSource ToReportSource(this IEnumerable<dynamic> source)
@tawman
tawman / Repository.cs
Created February 12, 2012 03:47
PetaPoco returning a PIVOT query as an IEnumerable<dynamic>
using System.Collections.Generic;
using PetaPoco;
namespace PetaPocoPivot.Services
{
public class Repository : IRepository
{
private readonly Database _database = new Database("AdventureWorks");
public IEnumerable<dynamic> GetEmployeeReport()
@tawman
tawman / HomeController.cs
Created February 12, 2012 03:58
An example ASP.NET MVC3 Controller wired up with a DoddleReport ReportResult Action
using System.Web.Mvc;
using DoddleReport;
using DoddleReport.Web;
using PetaPocoPivot.Services;
namespace PetaPocoPivot.Controllers
{
public class HomeController : Controller
{
private readonly IRepository _repository = new Repository();