/// <summary> /// Save session /// </summary> /// <param name="data">Test data</param> /// <param name="sessionId">Session id</param> /// <returns></returns> public static int Write(string data, int sessionId) { var session = db.TestSessions.FirstOrDefault(x => x.ID == sessionId); if (session != null) { session.ObjectData = data; db.ObjectStateManager.ChangeObjectState(session, EntityState.Modified); db.SaveChanges(); return session.ID; } else { session = new TestSession { ObjectData = data, Date = TimeManager.GetCurrentTime(), }; db.TestSessions.AddObject(session); db.SaveChanges(); return session.ID; } }
/// <summary> /// Deprecated Method for adding a new object to the TestSessions EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToTestSessions(TestSession testSession) { base.AddObject("TestSessions", testSession); }
/// <summary> /// Create a new TestSession object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="objectData">Initial value of the ObjectData property.</param> /// <param name="date">Initial value of the Date property.</param> public static TestSession CreateTestSession(global::System.Int32 id, global::System.String objectData, global::System.DateTime date) { TestSession testSession = new TestSession(); testSession.ID = id; testSession.ObjectData = objectData; testSession.Date = date; return testSession; }