예제 #1
0
        private static void TestIdentityMap()
        {
            MappingContext mappingContext = new MappingContext("ormExample");
            Client autocenter = new Client() {Address = "Garncarska 13 Krakow", Name = "Auto center"};
            mappingContext.ClientMapper.Insert(autocenter);
            mappingContext.SaveChanges();
            // TODO cannot use ID as the entity has not been inserted yet maybe mappingContext.SaveChanged()
            Client autoCenterFromDb = mappingContext.ClientMapper.GetById(autocenter.Id);
            Debug.Assert(autoCenterFromDb.GetHashCode() == autocenter.GetHashCode(), "identity map fails");

            Client firstClientAt3 = mappingContext.ClientMapper.GetById(2);
            Client secondClientAt3 = mappingContext.ClientMapper.GetById(2);
            Debug.Assert(firstClientAt3.GetHashCode() == secondClientAt3.GetHashCode(), "identity map fails");
        }
예제 #2
0
 private static void TestUow()
 {
     MappingContext mappingContext = new MappingContext("ormExample");
     Client c1 = mappingContext.ClientMapper.GetById(1);
     c1.Name += "UOW modified";
     mappingContext.SaveChanges();
     Client c2 = mappingContext.ClientMapper.GetById(1);
     Debug.Assert(c2.Name.Contains("UOW modified"));
 }