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