Exemplo n.º 1
0
 public static void ClearHistory()
 {
     using (var context = new PhotoDataContext())
     {
         context.Database.EnsureDeleted();
         context.Database.EnsureCreated();
     }
 }
Exemplo n.º 2
0
 public static IEnumerable <PhotoData> GetRecentPhotoDatas(int numberToRetrieve)
 {
     using (var context = new PhotoDataContext())
     {
         return(context.PhotoDatas
                .OrderByDescending(pd => pd.TimeOccurred)
                .Take(numberToRetrieve)
                .ToList());
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
        }