apex-enterprise-patterns / fflib-apex-common

Common Apex Library supporting Apex Enterprise Patterns and much more!
BSD 3-Clause "New" or "Revised" License
913 stars 517 forks source link

Reducing SOQL's shared by services #287

Closed konradbeck-creditech closed 1 year ago

konradbeck-creditech commented 4 years ago

Is there a good way to reduce the number of queries when multiple service methods use the same selector?

ImJohnMDaniel commented 4 years ago

@konradbeck-creditech, I am not certain that I understand what you are asking. Can you elaborate and provide some examples please?

afawcett commented 4 years ago

@konradbeck-creditech from a design perspective this sounds like a compound service scenario - thus move the queries into the compound service and pass the data sets into the child service as arguments (overloaded methods if you have existing client/caller code using them directly).

SWhalen-gh commented 4 years ago

an ability to cache data in a Selector or Service would be convenient, although overuse might be evidence of an anti-pattern somewhere in the code.