如何创建布尔值?

How to create Boolean?

我需要围绕 oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Acclaim, service)?.Expire(service); 创建一个 bool,如果 oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Acclaim, service) is not null

则将其设置为 true

关于如何执行此布尔值的任何建议?下面是我的代码?

public static void HandleLinkersForUpgrade(List<CatalogItemToOrganisationLinker> latestLinkers, List<CatalogItemToOrganisationLinker> oldLinkers, Account account, Invoice invoice, IOrganizationService service)
    {
        var newSupplierLinker = latestLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Supplier, service);
        var oldSupplierLinker = oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Supplier, service);

        var newSupplierLevel = newSupplierLinker?.ToTargetLevel(service);
        var oldSupplierLevel = oldSupplierLinker?.ToTargetLevel(service);

        if (newSupplierLevel > oldSupplierLevel)
        {
            //create the bool around line below
            oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Acclaim, service)?.Expire(service);
            oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.DTS, service)?.Expire(service);
            oldSupplierLinker.Expire(service);

        }

        var oldBuyerLinker = oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Buyer, service);
        var newBuyerLinker = latestLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Buyer, service);

        if (oldBuyerLinker != null && newBuyerLinker != null)
        {
            oldBuyerLinker.Expire(service);
        }

        foreach (var catItemLinker in latestLinkers)
        {
            if (catItemLinker.Category(service) == mm_catalogitemcategory.Acclaim)
            {
                UpgradeLogic.AcclaimUpgradeLogic(account, service);
            }

            if (oldSupplierLevel == 3)
            {
                var l3Linker = service.GetSetSectionToOrgLinker(account.Id, "L3");

                if (l3Linker?.SectionStatus == mm_status.Verified && catItemLinker.ToTargetLevel(service) == 4) // Hack to get OAR workflows to run
                {
                    l3Linker.SectionStatus = mm_status.AwaitingVerification;
                    l3Linker.Update(service);
                    l3Linker.SectionStatus = mm_status.Verified;
                    l3Linker.Update(service);
                }
            }

            catItemLinker.MakeLive(invoice, service);  
        }

        if (newSupplierLinker != null)
        {
            newSupplierLinker.TopAchievedCertificate = oldSupplierLinker?.TopAchievedCertificate;
            newSupplierLinker.Update(service);
        }
    }
bool result = oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Acclaim, service)?.Expire(service) ?? oldLinkers.GetNewestLinkerByCategory(mm_catalogitemcategory.Acclaim, service) != null ? true: false;

我觉得可以