public async Task SimpleSaveAndRetrieveAsync() { EmployeeWithCompositeKey emp = new EmployeeWithCompositeKey(1, 100); emp.StartDate = DateTime.Today; emp.FirstName = "Karl"; emp.Surname = "Chu"; emp.OtherNames = "The Yellow Dart"; emp.Title = "Rock Star"; objectsNeedDeleting.Add(emp); await(s.SaveAsync(emp)); await(s.FlushAsync()); s.Clear(); EmployeePk pk = new EmployeePk(1, 100); EmployeeWithCompositeKey retrieved = await(s.GetAsync <EmployeeWithCompositeKey>(pk)); Assert.IsNotNull(retrieved); Assert.AreEqual(emp.StartDate, retrieved.StartDate); Assert.AreEqual(emp.FirstName, retrieved.FirstName); Assert.AreEqual(emp.Surname, retrieved.Surname); Assert.AreEqual(emp.OtherNames, retrieved.OtherNames); Assert.AreEqual(emp.Title, retrieved.Title); }
public override bool Equals(object obj) { if (this.Pk == null) { return(false); } EmployeeWithCompositeKey other = obj as EmployeeWithCompositeKey; if (other == null) { return(false); } if (other.Pk == null) { return(false); } return(this.Pk.Equals(other.Pk)); }
public void SimpleSaveAndRetrieve() { EmployeeWithCompositeKey emp = new EmployeeWithCompositeKey(1, 100); emp.StartDate = DateTime.Today; emp.FirstName = "Karl"; emp.Surname = "Chu"; emp.OtherNames = "The Yellow Dart"; emp.Title = "Rock Star"; objectsNeedDeleting.Add(emp); s.Save(emp); s.Flush(); s.Clear(); EmployeePk pk = new EmployeePk(1, 100); EmployeeWithCompositeKey retrieved = s.Get<EmployeeWithCompositeKey>(pk); Assert.IsNotNull(retrieved); Assert.AreEqual(emp.StartDate, retrieved.StartDate); Assert.AreEqual(emp.FirstName, retrieved.FirstName); Assert.AreEqual(emp.Surname, retrieved.Surname); Assert.AreEqual(emp.OtherNames, retrieved.OtherNames); Assert.AreEqual(emp.Title, retrieved.Title); }