19.5k views
4 votes
Universal Containers has implemented a strict software architecture for their custom Apex code. One of the requirements is that all SOQL queries are contained within reusable classes. Depending on the context of the Apex transaction, the queries should be able to run either "With Sharing" or "Without Sharing". Which two ways allow the Architect to meet these requirements.

User Schack
by
6.8k points

1 Answer

7 votes

Answer:

The required coding for the architect to meet these requirement has been described below.

Step-by-step explanation:

The following ways will help the architecture to meet the requirement.

Create a reusable SOQLQueries class; specify “With Sharing” on the methods that require user context and “Without Sharing” on the methods requiring system context.

Create a SystemSOQLQueries class and a UserSOQLQueries class; set the “With Sharing” keyword on the UserSOQLQueries class and “Without Sharing” on the SystemSOQLQueries class.

User Lerner
by
7.1k points