Пример #1
0
 /// <summary>
 /// Execute Query[T].Where(query).FirstOrDefault();
 /// </summary>
 public T FirstOrDefault <T>(Expression <Func <T, bool> > predicate, string collectionName = null)
 {
     using (var db = new LiteRepository(_configService.ConnectionString))
     {
         return(db.FirstOrDefault <T>(predicate, collectionName));
     }
 }
Пример #2
0
 /// <summary>
 /// Execute Query[T].Where(query).FirstOrDefault();
 /// </summary>
 public T FirstOrDefault <T>(Query query = null, string collectionName = null)
 {
     using (var db = new LiteRepository(_configService.ConnectionString))
     {
         return(db.FirstOrDefault <T>(query, collectionName));
     }
 }
Пример #3
0
 public TModel GetById(int id)
 {
     using (var db = new LiteRepository(_connectionString))
     {
         return(db.FirstOrDefault <TModel>(x => x.Id == id && !x.Removed));
     }
 }
Пример #4
0
 public Optional <Settings> GetSettingsForUser(string userName)
 {
     using (var repository = new LiteRepository(_connectionStringProvider.ConnectionString))
     {
         var entity = repository.FirstOrDefault <Settings>(p => p.UserName == userName);
         return(entity == null ? Optional <Settings> .Empty() : Optional <Settings> .For(entity));
     }
 }
Пример #5
0
 public Optional <InferenceProfile> GetProfileByName(string profileName)
 {
     using (var repository = new LiteRepository(_connectionStringProvider.ConnectionString))
     {
         var entity = repository.FirstOrDefault <InferenceProfile>(p => p.ProfileName == profileName);
         return(entity == null ? Optional <InferenceProfile> .Empty() : Optional <InferenceProfile> .For(entity));
     }
 }
Пример #6
0
        public Result <T> FirstOrDefault(Query query = null, string collectionName = null)
        {
            var result = new Result <T>();

            try
            {
                result.ResultObject = _liteRepository.FirstOrDefault <T>(query, collectionName);
            }
            catch (Exception ex)
            {
                result.ResultCode         = (int)ResultStatusCode.InternalServerError;
                result.ResultMessage      = "Hata Oluştu => " + ex;
                result.ResultInnerMessage = "Hata Oluştu => " + ex.InnerException;

                result.ResultStatus = false;
            }

            return(result);
        }
Пример #7
0
        public Security GetSecurity()
        {
            var security = _repository.FirstOrDefault <Security>();

            if (security != null)
            {
                return(security);
            }

            security = new Security();
            _repository.Insert(security, "security");
            return(security);
        }
Пример #8
0
        public bool Remove(int id)
        {
            using (var db = new LiteRepository(_connectionString))
            {
                var entity = db.FirstOrDefault <TModel>(x => x.Id == id && !x.Removed);
                if (entity == null)
                {
                    return(false);
                }

                entity.Removed = true;
                return(db.Update(entity));
            }
        }
Пример #9
0
 private void AddTagIfNotExists(IEnumerable <TagDto> tags)
 {
     using (var db = new LiteRepository(_connectionString))
     {
         foreach (var tag in tags)
         {
             var exists = db.FirstOrDefault <TagDto>(x => x.NormalizedName == tag.NormalizedName);
             if (exists == null)
             {
                 db.Insert <TagDto>(tag);
             }
         }
     }
 }
Пример #10
0
        public UserModel Get(Guid id)
        {
            if (id == Guid.Empty)
            {
                throw new ArgumentNullException(nameof(id));
            }

            var result = _instance.FirstOrDefault <UserModel>(x => x.Id == id);

            if (result == null)
            {
                throw new Exception("No user found");
            }

            return(result);
        }
Пример #11
0
        static Database()
        {
            Repo            = new LiteRepository("config.db");
            DB              = Repo.Database;
            InternalOptions = Repo.FirstOrDefault <InternalOptions>();

            if (InternalOptions == null)
            {
                InternalOptions = new InternalOptions();
                return;
            }

            // check if InternalOptions are valid
            InternalOptions.MaxModifications = Math.Max(InternalOptions.MaxModifications, 0);
            InternalOptions.Duration         = Math.Max(InternalOptions.Duration, MIN_DURATION);

            Repo.Upsert(InternalOptions);
        }
Пример #12
0
 public T GetRawDtoById <T>(Id <T> id)
     where T : IHasId <T>
 {
     return(repo.FirstOrDefault <T>(x => x.Id == id));
 }
Пример #13
0
 public T FirstOrDefault(Expression <Func <T, bool> > predicate)
 {
     return(_liteRepository.FirstOrDefault(predicate));
 }
Пример #14
0
 public PluginEntity GetPluginByGuid(Guid pluginGuid)
 {
     return(_repository.FirstOrDefault <PluginEntity>(p => p.Id == pluginGuid));
 }
Пример #15
0
        private static PdfFile GetPdf(this LiteRepository repo, string contentMd5)
        {
            var md5 = contentMd5.ToLowerInvariant();

            return(repo.FirstOrDefault <PdfFile>(p => p.Md5 == md5));
        }
Пример #16
0
 public ModuleSettingsEntity GetByPluginGuid(Guid guid)
 {
     return(_repository.FirstOrDefault <ModuleSettingsEntity>(s => s.PluginGuid == guid));
 }
Пример #17
0
 public ProfileEntity Get(Guid id)
 {
     return(_repository.FirstOrDefault <ProfileEntity>(p => p.Id == id));
 }
Пример #18
0
 public DeviceEntity Get(string id)
 {
     return(_repository.FirstOrDefault <DeviceEntity>(s => s.Id == id));
 }
Пример #19
0
 public PluginSettingEntity GetByNameAndPluginGuid(string name, Guid pluginGuid)
 {
     return(_repository.FirstOrDefault <PluginSettingEntity>(p => p.Name == name && p.PluginGuid == pluginGuid));
 }
Пример #20
0
 public ModuleSettingsEntity GetByModuleId(string moduleId)
 {
     return(_repository.FirstOrDefault <ModuleSettingsEntity>(s => s.ModuleId == moduleId));
 }
Пример #21
0
 public async Task <TAggregate> Get(TKey key)
 {
     return(Db.FirstOrDefault <TAggregate>(a => a.Id == key));
 }
Пример #22
0
 public SurfaceEntity GetByName(string name)
 {
     return(_repository.FirstOrDefault <SurfaceEntity>(s => s.Name == name));
 }
Пример #23
0
 public Person Read(string id) => repository.FirstOrDefault <Person>(x => x.Id == id);
Пример #24
0
 public Letter Read(string id) => repository.FirstOrDefault <Letter>(x => x.Id == id);
Пример #25
0
 public Task <Session> GetSession(Guid sessionId)
 {
     return(Task.FromResult(repo.FirstOrDefault <Session>(x => x.SessionId == sessionId)));
 }