예제 #1
0
        public void TestCreateParentChildCompositeKey()
        {
            using (var context = GetContext())
            {
                var parent = new BaseEntity{Id="foo"};
                context.BaseEntities.Add(parent);
                var child = new ChildKeyEntity {Parent = parent, Position = 1};
                var child2 = new ChildKeyEntity {Parent = parent, Position = 2};
                context.ChildKeyEntities.Add(child);
                context.ChildKeyEntities.Add(child2);
                context.SaveChanges();
            }

            using (var context = GetContext())
            {
                var entity = context.ChildKeyEntities.FirstOrDefault(x => x.Id.Equals("foo/1"));
                Assert.That(entity, Is.Not.Null);
                var entity2 = context.ChildKeyEntities.FirstOrDefault(x => x.Id.Equals("foo/2"));
                Assert.That(entity2, Is.Not.Null);
            }
        }
예제 #2
0
 public void TestCreateEntityWithNoContext()
 {
     MyEntityContext.InitializeEntityMappingStore();
     var entity = new BaseEntity {Id = "foo"};
 }