public void InsertEntitiesWithOneToManyRelationship() { var disconnectedInsertMapper = new DisconnectedInsertMapper(); disconnectedInsertMapper.CleanAllRecordsFromPrincipalAndDependentEntitiesByConventionOTM(); var firstPrincipalEntityByConventionOTM = new PrincipalEntityByConventionOTM() { FirstProperty = 100, SecondProperty = "example that will add the two entities" }; var firstDependentEntityByConventionOTM = new DependentEntityByConventionOTM() { FirstProperty = 50, SecondProperty = 556.89m }; var secondDependentEntityByConventionOTM = new DependentEntityByConventionOTM() { FirstProperty = 100, SecondProperty = 116.69m }; firstPrincipalEntityByConventionOTM.DependentsEntitiesByConventionOTM = new List <DependentEntityByConventionOTM>(); firstPrincipalEntityByConventionOTM.DependentsEntitiesByConventionOTM.Add(firstDependentEntityByConventionOTM); firstPrincipalEntityByConventionOTM.DependentsEntitiesByConventionOTM.Add(secondDependentEntityByConventionOTM); disconnectedInsertMapper.InsertEntitiesWithOneToManyRelationship(firstPrincipalEntityByConventionOTM); }
public void InsertEntitiesWithOneToManyRelationship(PrincipalEntityByConventionOTM principalEntityByConventionOTM) { using (var experimentsDbContext = new ExperimentsDbContext()) { experimentsDbContext.PrincipalEntityByConventionOTM.AddRange(principalEntityByConventionOTM); experimentsDbContext.SaveChanges(); } }
public void UpdateEntitiesWithOneToManyRelationship() { InsertEntitiesWithOneToManyRelationship(); var disconnectedUpdateMapper = new DisconnectedUpdateMapper(); var firstPrincipalEntityByConventionOTM = new PrincipalEntityByConventionOTM() { Id = 1, FirstProperty = 100, SecondProperty = "example that will update the entities", DependentsEntitiesByConventionOTM = new List <DependentEntityByConventionOTM>() { new DependentEntityByConventionOTM() { Id = 1, FirstProperty = 50, SecondProperty = 12.45m } } }; disconnectedUpdateMapper.UpdateEntitiesWithOneToManyRelationship(firstPrincipalEntityByConventionOTM); }