Пример #1
0
 public static void ClearHistory()
 {
     using (var context = new PhotoDataContext())
     {
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
     }
 }
Пример #2
0
 public static IEnumerable <PhotoData> GetRecentPhotoDatas(int numberToRetrieve)
 {
     using (var context = new PhotoDataContext())
     {
         return(context.PhotoDatas
                .OrderByDescending(pd => pd.TimeOccurred)
                .Take(numberToRetrieve)
                .ToList());
     }
 }
Пример #3
0
 /// <summary>
 /// Initializes the singleton application object.  This is the first line of authored code
 /// executed, and as such is the logical equivalent of main() or WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     using (var context = new PhotoDataContext())
     {
         context.Database.EnsureCreated();
         context.Database.Migrate();
     }
 }
Пример #4
0
        public static PhotoData RecordPhotoData(string metadata, byte[] bmp)
        {
            var photoData = new PhotoData
            {
                Id           = Guid.NewGuid(),
                Metadata     = metadata,
                TimeOccurred = DateTime.UtcNow
            }; //,                Image = bmp             };

            using (var context = new PhotoDataContext())
            {
                context.PhotoDatas.Add(photoData);
                context.SaveChanges();
            }

            return(photoData);
        }