Esempio n. 1
0
        public void UpdateEntitiesWithManyToManyRelationship()
        {
            InsertEntitiesWithManyToManyRelationship();

            var disconnectedUpdateMapper = new DisconnectedUpdateMapper();

            var principalEntityByConventionMTM = new PrincipalEntityByConventionMTM()
            {
                FirstProperty  = 200,
                SecondProperty = "another entity"
            };

            var dependentEntityByConventionMTM = new DependentEntityByConventionMTM()
            {
                FirstProperty  = 200,
                SecondProperty = 13.78m
            };

            new DisconnectedInsertMapper().InsertEntitiesWithoutRelationship(principalEntityByConventionMTM, dependentEntityByConventionMTM);

            var middleEntityByConventionMTM = new MiddleEntityByConventionMTM()
            {
                Id = 1,
                PrincipalEntityByConventionMTMId = 1,
                DependentEntityByConventionMTMId = 2
            };

            disconnectedUpdateMapper.UpdateEntitiesWithManyToManyRelationship(middleEntityByConventionMTM);
        }
 public void InsertEntitiesWithoutRelationship(PrincipalEntityByConventionMTM principalEntityByConventionMTM,
                                               DependentEntityByConventionMTM dependentEntityByConventionMTM)
 {
     using (var experimentsDbContext = new ExperimentsDbContext())
     {
         experimentsDbContext.PrincipalEntityByConventionMTM.AddRange(principalEntityByConventionMTM);
         experimentsDbContext.DependentEntityByConventionMTM.AddRange(dependentEntityByConventionMTM);
         experimentsDbContext.SaveChanges();
     }
 }
        public void InsertEntitiesWithManyToManyRelationship(PrincipalEntityByConventionMTM principalEntityByConventionMTM,
                                                             DependentEntityByConventionMTM dependentEntityByConventionMTM)
        {
            using (var experimentsDbContext = new ExperimentsDbContext())
            {
                experimentsDbContext.PrincipalEntityByConventionMTM.AddRange(principalEntityByConventionMTM);
                experimentsDbContext.DependentEntityByConventionMTM.AddRange(dependentEntityByConventionMTM);
                experimentsDbContext.SaveChanges();

                var middleEntityByConventionMTM = new MiddleEntityByConventionMTM()
                {
                    PrincipalEntityByConventionMTMId = principalEntityByConventionMTM.Id,
                    DependentEntityByConventionMTMId = dependentEntityByConventionMTM.Id
                };

                experimentsDbContext.MiddleEntityByConventionMTM.AddRange(middleEntityByConventionMTM);
                experimentsDbContext.SaveChanges();
            }
        }
Esempio n. 4
0
        public void InsertEntitiesWithManyToManyRelationship()
        {
            var disconnectedInsertMapper = new DisconnectedInsertMapper();

            disconnectedInsertMapper.CleanAllRecordsFromPrincipalAndDependentEntitiesByConventionMTM();

            var principalEntityByConventionMTM = new PrincipalEntityByConventionMTM()
            {
                FirstProperty  = 100,
                SecondProperty = "example that will add the two entities"
            };

            var dependentEntityByConventionMTM = new DependentEntityByConventionMTM()
            {
                FirstProperty  = 100,
                SecondProperty = 64.89m
            };

            disconnectedInsertMapper.InsertEntitiesWithManyToManyRelationship(principalEntityByConventionMTM, dependentEntityByConventionMTM);
        }