public void get_not_created_entity() { var key = Guid.NewGuid(); int entity; Assert.AreEqual(false, _reader.TryGet(key, out entity)); }
public static Maybe <TSingleton> Get <TSingleton>(this IDocumentReader <unit, TSingleton> reader) { TSingleton singleton; if (reader.TryGet(unit.it, out singleton)) { return(singleton); } return(Maybe <TSingleton> .Empty); }
public static Maybe <TEntity> Get <TKey, TEntity>(this IDocumentReader <TKey, TEntity> self, TKey key) { TEntity entity; if (self.TryGet(key, out entity)) { return(entity); } return(Maybe <TEntity> .Empty); }
public static TView GetOrNew <TView>(this IDocumentReader <unit, TView> reader) where TView : new() { TView view; if (reader.TryGet(unit.it, out view)) { return(view); } return(new TView()); }
public static TEntity Load <TKey, TEntity>(this IDocumentReader <TKey, TEntity> reader, TKey key) { TEntity entity; if (reader.TryGet(key, out entity)) { return(entity); } var txt = string.Format("Failed to load '{0}' with key '{1}'.", typeof(TEntity).Name, key); throw new InvalidOperationException(txt); }