public void SavePackageComponents(int OwningPackageId, PackageComponent[] Components) { Package package = new Package(OwningPackageId); package.ClearPackageComponents(); foreach (PackageComponent c in Components) { c.PackageId = OwningPackageId; PackageComponent newComponent = c.Create(); // Attach the products foreach (string productId in c.ProductsString.Split(',')) if (!String.IsNullOrEmpty(productId)) newComponent.AttachProduct(Convert.ToInt32(productId)); } }