Ejemplo n.º 1
0
 private void EnsureDBCreated()
 {
     using (SqliteLocalFileIndexDBContext dbContext = new SqliteLocalFileIndexDBContext())
     {
         dbContext.Database.EnsureCreated();
     }
 }
Ejemplo n.º 2
0
        private void saveLocalFileIndex(StoredFile indexInfo)
        {
            if (indexInfo == null || string.IsNullOrEmpty(indexInfo.fileFullName))
            {
                throw new ArgumentNullException("indexInfo or indexInfo.fileFullName is null");
            }

            using (SqliteLocalFileIndexDBContext dbContext = new SqliteLocalFileIndexDBContext())
            {
                try
                {
                    dbContext.Files.Add(indexInfo);
                    dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Ejemplo n.º 3
0
        private StoredFile SearchFileInFileIndex(string fileUniqueName)
        {
            using (SqliteLocalFileIndexDBContext dbContext = new SqliteLocalFileIndexDBContext())
            {
                try
                {
                    var fileInfo = (from f in dbContext.Files
                                    where f.fileUniqueName.Equals(fileUniqueName)
                                    select f).FirstOrDefault();

                    if (fileInfo != null)
                    {
                        return(fileInfo);
                    }
                }
                catch (Exception e)
                {
                    throw e;
                }
            }

            return(null);
        }