| 123456789101112131415161718192021222324252627282930313233343536373839 | using System.Linq.Expressions;using Comal.Classes;using InABox.Core;using InABox.Database;namespace PRS.Shared;public class Update_6_43 : DatabaseUpdateScript{    public override VersionNumber Version => new (6, 43);            public override bool Update()    {        Logger.Send(LogType.Information, "", "Converting Supplier/Product Links");        List<SupplierProduct> updates = new List<SupplierProduct>();        var columns = new Columns<SupplierProduct>(x => x.ID).Add(x=>x.Product.ID);        columns.Add("ProductLink.ID");        CoreTable products = DbFactory.Provider.Query<SupplierProduct>(null, columns);        foreach (var row in products.Rows)        {            Guid id = row.Get<SupplierProduct,Guid>(x=>x.ID);            Guid oldid = row.Get<Guid>("ProductLink.ID");            Guid newid = row.Get<SupplierProduct,Guid>(x=>x.Product.ID);            if ((oldid != Guid.Empty) && (newid == Guid.Empty))            {                var update = new SupplierProduct() { ID = id };                update.CommitChanges();                update.Product.ID = oldid;                updates.Add(update);            }        }        DbFactory.Provider.Save(updates);        return true;    }    }
 |