This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |