To be able to scale I would like to use async programming. It works really well if I have to read something from db and push to frontend, however I do not know how to use it correctly in blobs of buniess logic that live their own lives. I have object, that has lots of properties that should be lazy loaded. For instance Order class that has Recipient, Payer, DeliveryAddress etc. It groups services that read something based on orderId.
In old times I would do:
Payer payer = order.Payer;
- it would check request cache and query base as needed. However now I have Payer payer = await order.Payer()
and I hate it. It forces all my logic code to be asynchronous (because in accounting software Payer needs to be everywhere).
How to solve this problem?
(await order.GetPayer()).DoSomething()
.