Example #1
0
 public static void Clear()
 {
     using (var db = new BigFileDbContext())
     {
         db.Database.EnsureDeleted();
         db.Database.EnsureCreated();
     }
 }
Example #2
0
 public static int Delete(string filePath)
 {
     using (var db = new BigFileDbContext())
     {
         var existing = db.BigFiles.Where(it => it.FilePath == filePath);
         db.BigFiles.RemoveRange(existing);
         return(db.SaveChanges());
     }
 }
Example #3
0
 public static Message Add(Message message)
 {
     using (var db = new BigFileDbContext())
     {
         db.Messages.Add(message);
         db.SaveChanges();
         return(message);
     }
 }
Example #4
0
 public static BigFile Add(BigFile bigFile)
 {
     using (var db = new BigFileDbContext())
     {
         db.BigFiles.Add(bigFile);
         db.SaveChanges();
         return(bigFile);
     }
 }
Example #5
0
 public static int Delete(IEnumerable <Message> messages)
 {
     using (var db = new BigFileDbContext())
     {
         db.Messages.AttachRange(messages);
         foreach (var item in db.ChangeTracker.Entries())
         {
             item.State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
         }
         return(db.SaveChanges());
     }
 }
Example #6
0
 public static int Delete(BigFile bifFile)
 {
     using (var db = new BigFileDbContext())
     {
         db.AttachRange(bifFile);
         foreach (var item in db.ChangeTracker.Entries())
         {
             item.State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
         }
         return(db.SaveChanges());
     }
 }
Example #7
0
 public static IEnumerable <BigFile> Search(string fileNameLike, long?greaterThanfileSize, int pageIndex = 0, int pageSize = 100)
 {
     using (var db = new BigFileDbContext())
     {
         var queryable = db.BigFiles as IQueryable <BigFile>;
         if (!string.IsNullOrWhiteSpace(fileNameLike))
         {
             queryable = queryable.Where(it => it.FileName.Contains(fileNameLike));
         }
         if (greaterThanfileSize != null)
         {
             queryable = queryable.Where(it => it.Length >= greaterThanfileSize);
         }
         queryable = queryable.Skip(pageIndex * pageSize).Take(pageSize);
         return(queryable.ToList());
     }
 }
Example #8
0
 public static IEnumerable <Message> Search(string exceptionMessageLike, string fileOrFolderNameLike, MessageType?messageType, int pageIndex = 0, int pageSize = 100)
 {
     using (var db = new BigFileDbContext())
     {
         var queryable = db.Messages as IQueryable <Message>;
         if (!string.IsNullOrWhiteSpace(exceptionMessageLike))
         {
             queryable = queryable.Where(it => it.ExceptionMessage.Contains(exceptionMessageLike));
         }
         if (!string.IsNullOrWhiteSpace(fileOrFolderNameLike))
         {
             queryable = queryable.Where(it => it.FilePath.Contains(fileOrFolderNameLike) || it.FolderPath.Contains(fileOrFolderNameLike));
         }
         if (messageType != null)
         {
             queryable = queryable.Where(it => it.MessageType == messageType);
         }
         queryable = queryable.Skip(pageIndex * pageSize).Take(pageSize);
         return(queryable.ToList());
     }
 }