public static LwoObject CopyObject(this AccessDatabase @this, int lot, int id = -1) { var source = @this.LoadObject(lot); var destination = @this.NewObject(id); foreach (var column in source.Row) { if (column.Name == "id") { continue; } destination.Row[column.Name].Value = column.Value; destination.Row[column.Name].Type = column.Type; } foreach (var component in source) { var destinationComponent = new LwoComponent(component.Id); destination.Add(destinationComponent); var sourceRow = component.Row; if (sourceRow == default) { continue; } var destinationRow = destinationComponent.Row; foreach (var column in sourceRow) { if (column.Name == "id") { continue; } destinationRow[column.Name].Value = column.Value; destinationRow[column.Name].Type = column.Type; } } return(destination); }