protected void UpdateEntitiesIdentity <T>(Type type, IList <T> entities, IList <T> entitiesWithOutputIdentity) { if (BulkConfig.PreserveInsertOrder) // Updates PK in entityList { string identityPropertyName = OutputPropertyColumnNamesDict.SingleOrDefault(a => a.Value == IdentityColumnName).Key; for (int i = 0; i < NumberOfEntities; i++) { var propertyValue = FastPropertyDict[identityPropertyName].Get(entitiesWithOutputIdentity[i]); FastPropertyDict[identityPropertyName].Set(entities[i], propertyValue); if (TimeStampColumnName != null) // timestamp/rowversion is also generated by the SqlServer so if exist should ba updated as well { string timeStampPropertyName = OutputPropertyColumnNamesDict.SingleOrDefault(a => a.Value == TimeStampColumnName).Key; var timeStampPropertyValue = FastPropertyDict[timeStampPropertyName].Get(entitiesWithOutputIdentity[i]); FastPropertyDict[timeStampPropertyName].Set(entities[i], timeStampPropertyValue); } } } else // Clears entityList and then refills it with loaded entites from Db { entities.Clear(); ((List <T>)entities).AddRange(entitiesWithOutputIdentity); } }
protected void UpdateEntitiesIdentity <T>(IList <T> entities, IList <T> entitiesWithOutputIdentity) { if (BulkConfig.PreserveInsertOrder) // Updates PK in entityList { var accessor = TypeAccessor.Create(typeof(T), true); string identityPropertyName = OutputPropertyColumnNamesDict.SingleOrDefault(a => a.Value == IdentityColumnName).Key; for (int i = 0; i < NumberOfEntities; i++) { accessor[entities[i], identityPropertyName] = accessor[entitiesWithOutputIdentity[i], identityPropertyName]; if (TimeStampColumnName != null) // timestamp/rowversion is also generated by the SqlServer so if exist should ba updated as well { accessor[entities[i], TimeStampColumnName] = accessor[entitiesWithOutputIdentity[i], TimeStampColumnName]; } } } else // Clears entityList and then refills it with loaded entites from Db { entities.Clear(); ((List <T>)entities).AddRange(entitiesWithOutputIdentity); } }