Example #1
0
        public static void TestRepositoryPattern()
        {
            var storeName = "TestRepositoryPattern" + DateTime.Now.Ticks;
            string id;

            using ( var context = new MyEntityContext())
            {
                var uow = new TempUnitOfWork(context);
                var repo = new TempRepository<IPerson>(uow);
                var derived = repo.Create();
                derived.FirstName = "Danny";
                derived.FirstName = "Mayers";

                context.SaveChanges();
                id = derived.Id;
            }

            using ( var context = new MyEntityContext())
            {
                var uow = new TempUnitOfWork(context);
                var repo = new TempRepository<IPerson>(uow);
                var derived = repo.GetById(id);

            }
        }
Example #2
0
        static void MainDirect()
        {
            MyEntityContext context = new MyEntityContext();

            var person1 = new Person();
            person1.FirstName = "Juliet";
            person1.LastName = "Binoche";
            person1.Id = "Juliet_Binoche";

            context.Persons.Add(person1);

            var production1 = new Production();
            production1.Title = "Mademoiselle_Julie_2012";
            production1.Id = "Mademoiselle_Julie_2012";

            context.Productions.Add(production1);

            var character1 = new Character();
            character1.Name = "Mademoiselle_Julie";
            character1.Id = "Mademoiselle_Julie";
            context.Characters.Add(character1);

            var credit1 = new Credit();
            credit1.Label = "Actor";
            credit1.Id = "actor";
            context.Credits.Add(credit1);

            var role1 = new Role();
            role1.Production = production1;
            role1.Character = character1;
            role1.Credit = credit1;
            context.Roles.Add(role1);

            production1.Performers.Add(person1);
            person1.Roles.Add(role1);

            context.SaveChanges();
        }