Skip to content

Instantly share code, notes, and snippets.

View mikeeast's full-sized avatar

Mikael Östberg mikeeast

View GitHub Profile
@mikeeast
mikeeast / gist:4175450
Created November 30, 2012 12:15
GetValueSafe extension method
public static TResult GetValueSafe<TInstance, TResult>(this TInstance instance, Func<TInstance, TResult> accessor, TResult defaultValue = default(TResult))
where TInstance : class
{
return instance != null ? accessor(instance) : defaultValue;
}
usage:
someNullableObject.GetValueSafe(p => p.SomeProperty)
or
@mikeeast
mikeeast / Event.cs
Last active December 17, 2015 08:49
This is how I perform the poor man's message reordering.
using System;
namespace MyNamespace.ReadModel.Data.Models
{
public class Event
{
public int EventVersion { get; set; }
public int CommitVersion { get; set; }
public DateTime ReceivedDate { get; set; }
public DateTime EventDate { get; set; }