private static DeletionDataDefinition GetData(object dataAsAnonymousType) { var data = new DeletionDataDefinition(); var properties = TypeDescriptor.GetProperties(dataAsAnonymousType); foreach (PropertyDescriptor property in properties) data.Add(new KeyValuePair<string, object>(property.Name, property.GetValue(dataAsAnonymousType))); return data; }
private static DeletionDataDefinition GetData(object dataAsAnonymousType) { var data = new DeletionDataDefinition(); var properties = TypeDescriptor.GetProperties(dataAsAnonymousType); foreach (PropertyDescriptor property in properties) { data.Add(new KeyValuePair <string, object>(property.Name, property.GetValue(dataAsAnonymousType))); } return(data); }
/// <inheritdoc /> public IMigrationExpression Reverse() { var expression = new DeleteDataExpression { SchemaName = SchemaName, TableName = TableName }; foreach (var row in Rows) { var dataDefinition = new DeletionDataDefinition(); dataDefinition.AddRange(row); expression.Rows.Add(dataDefinition); } return(expression); }
private static DeletionDataDefinition GetData(object dataAsAnonymousType) { var data = new DeletionDataDefinition(); #if NETSTANDARD var properties = dataAsAnonymousType.GetType().GetTypeInfo().DeclaredProperties; foreach (var property in properties) data.Add(new KeyValuePair<string, object>(property.Name, property.GetValue(dataAsAnonymousType))); #else var properties = TypeDescriptor.GetProperties(dataAsAnonymousType); foreach (PropertyDescriptor property in properties) data.Add(new KeyValuePair<string, object>(property.Name, property.GetValue(dataAsAnonymousType))); #endif return data; }
public void Truncate(DeleteDataExpression expression) { expression.TableName = Truncate(expression.TableName); List <DeletionDataDefinition> deletions = new List <DeletionDataDefinition>(); foreach (DeletionDataDefinition deletion in expression.Rows) { DeletionDataDefinition newDeletion = new DeletionDataDefinition(); foreach (var data in deletion) { newDeletion.Add(new KeyValuePair <string, object>(Truncate(data.Key), data.Value)); } deletions.Add(newDeletion); } expression.Rows.Clear(); expression.Rows.AddRange(deletions); }
public IMigrationExpression Reverse() { var expression = new DeleteDataExpression { SchemaName = SchemaName, TableName = TableName }; foreach (var row in Rows) { var dataDefinition = new DeletionDataDefinition(); dataDefinition.AddRange(row); expression.Rows.Add(dataDefinition); } return expression; }
private static DeletionDataDefinition GetData(object dataAsAnonymousType) { var data = new DeletionDataDefinition(); #if COREFX var properties = dataAsAnonymousType.GetType().GetTypeInfo().DeclaredProperties; foreach (var property in properties) { data.Add(new KeyValuePair <string, object>(property.Name, property.GetValue(dataAsAnonymousType))); } #else var properties = TypeDescriptor.GetProperties(dataAsAnonymousType); foreach (PropertyDescriptor property in properties) { data.Add(new KeyValuePair <string, object>(property.Name, property.GetValue(dataAsAnonymousType))); } #endif return(data); }
public void Truncate(DeleteDataExpression expression) { expression.TableName = Truncate(expression.TableName); List<DeletionDataDefinition> deletions = new List<DeletionDataDefinition>(); foreach (DeletionDataDefinition deletion in expression.Rows) { DeletionDataDefinition newDeletion = new DeletionDataDefinition(); foreach (var data in deletion) { newDeletion.Add(new KeyValuePair<string, object>(Truncate(data.Key), data.Value)); } deletions.Add(newDeletion); } expression.Rows.Clear(); expression.Rows.AddRange(deletions); }