Best way to call BO method from inside a function c#

I have made this work in the past but I’d like to know for future sake what the best way to access a BO/service method from inside a c# code block in a function. I understand something about the Db context not being there… wondering if there’s a “best practice”? Is it going to a REST call? Or what?

Thanks in advance!

CallService (usually)

1 Like

I’d write you an example but I’m on a phone in a plane. :rofl:

1 Like

Thank you, sir!

1 Like

If it is still needed:

CallService<ContractType>(svc => 
{
  svc.MethodName();
});

Usually the contract types will be in either Ice.Contracts or Erp.Contracts.

Example:

CallService<Ice.Contracts.MetaFXSvcContract>(svc =>
{
    var request = new EpMetaFxRequest()
    {
        id = "AppName",
        properties = new EpMetaFxRequestProperty()
        {
            deviceType = "Desktop",
            layers = new string[] { "LayerName" },
            mode = "AppStudio",
            layerType = "",
            baseAppVersion = 0,
            layerVersion = 0,
            applicationType = "view",
            additionalContext = new Dictionary<string, object>()
            {
                { "inPreviewMode", true },
            },
            checkDuplicateIds = false,
            debug = false
        }
    };
  
    var app = svc.GetApp(request);

});
5 Likes