public void LogSynchronization() { Synchronization sync = new Synchronization(); try { sync.SyncDate = DateTime.UtcNow; if ((from s in _hardcardContext.Synchronizations select s.Id).Count() > 0) { sync.Id = (from s in _hardcardContext.Synchronizations select s.Id).Max() + 1; } else { sync.Id = 1000; } _hardcardContext.AddToSynchronizations(sync); _hardcardContext.SaveChanges(); } catch (Exception ex) { /*Need better error logging or display*/ System.Console.WriteLine(ex.Message); } }
/// <summary> /// Deprecated Method for adding a new object to the Synchronizations EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToSynchronizations(Synchronization synchronization) { base.AddObject("Synchronizations", synchronization); }
/// <summary> /// Create a new Synchronization object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="syncDate">Initial value of the SyncDate property.</param> public static Synchronization CreateSynchronization(global::System.Int32 id, global::System.DateTime syncDate) { Synchronization synchronization = new Synchronization(); synchronization.Id = id; synchronization.SyncDate = syncDate; return synchronization; }