protected TModel FindOne <TModel>(OneOptions options) where TModel : class, new() { if (options == null) { throw new ArgumentNullException("options"); } TModel result = null; if (options.UseCache) { result = Cache.Get <TModel>(GetScopedCacheKey(options.CacheKey)); } if (result != null) { return(result); } if (Mapper.FindTypeMapFor <T, TModel>() == null) { Mapper.CreateMap <T, TModel>(); } var query = options.ApplyFilter(Collection.AsQueryable()); result = Mapper.Map <T, TModel>(query.FirstOrDefault()); if (result != null && options.UseCache) { Cache.Set(GetScopedCacheKey(options.CacheKey), result, options.GetCacheExpirationDate()); } return(result); }
protected bool Exists(OneOptions <T> options) { if (options == null) { throw new ArgumentNullException("options"); } var query = options.ApplyFilter(Collection.AsQueryable()); return(query.Any()); }