protected SimpleBenchmarkEntity GenerateSimpleBenchmarkEntity(int entityIndex, SimpleBenchmarkEntity entity = null)
        {
            if (entity == null)
            {
                entity = new SimpleBenchmarkEntity();
            }

            entity.FirstName = $"First Name {entityIndex}";
            entity.LastName = $"Last Name {entityIndex}";
            entity.DateOfBirth = new SqlDateTime(DateTime.Now).Value;

            return entity;
        }
Ejemplo n.º 2
0
        public void WhenIUpdateAllTheSingleIntKeyEntitiesThatIPreviouslyInsertedUsingEntityFramework()
        {
            var entityCount = _testContext.LocalEntities.Count;

            for (var entityIndex = 0; entityIndex < _testContext.LocalEntities.Count; entityIndex++)
            {
                var oldEntity = _testContext.LocalEntities[entityIndex] as SimpleBenchmarkEntity;
                var newEntity = new SimpleBenchmarkEntity();
                newEntity.Id = oldEntity.Id;

                using (var dbContext = new EfDbContext(_testContext.DatabaseConnection, _compiledModel, false))
                {
                    dbContext.BenchmarkEntities.Attach(newEntity);
                    this.GenerateSimpleBenchmarkEntity(entityCount++, newEntity);
                    dbContext.SaveChanges();
                }
                _testContext.LocalEntities[entityIndex] = newEntity;
            }
        }
 protected bool Equals(SimpleBenchmarkEntity other)
 {
     return(this.Id == other.Id && string.Equals(this.FirstName, other.FirstName) && string.Equals(this.LastName, other.LastName) && this.DateOfBirth.Equals(other.DateOfBirth));
 }
 protected bool Equals(SimpleBenchmarkEntity other)
 {
     return this.Id == other.Id && string.Equals(this.FirstName, other.FirstName) && string.Equals(this.LastName, other.LastName) && this.DateOfBirth.Equals(other.DateOfBirth);
 }