Exemple #1
0
        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)
        {
            EmployeePk other = obj as EmployeePk;

            if (other == null)
            {
                return(false);
            }
            else
            {
                return(this.CompanyId == other.CompanyId && string.Equals(this.EmpNumber, other.EmpNumber));
            }
        }
		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);
		}