-
Notifications
You must be signed in to change notification settings - Fork 53
Open
Description
What is the best way to have one selector implementation and be able to choose to have a with sharing and a without sharing selector, with the minimal amount of code duplication.
I currently have something like this, but how do I implement this in AT4DX:
public interface IContactsSelector extend fflib_ISObjectSelector
{
List<Contact> selectById(Set<Id> ids);
}
pubic virtual inherited sharing class ContactsSelector extends fflib_SObjectSelector implements IContactsSelector
{
public static IContactsSelector newInstance()
{
return (IContactsSelector) Application.Selector.newInstance(Schema.Contact.SObjectType);
}
public static IContactsSelector newWithoutSharingInstance()
{
return (IContactsSelector) Application.WithoutSharingSelector.newInstance(Schema.Contact.SObjectType);
}
public static IContactsSelector newWithSharingInstance()
{
return (IContactsSelector) Application.WithSharingSelector.newInstance(Schema.Contact.SObjectType);
}
public ContactsSelector()
{
super();
}
public ContactsSelector(Boolean includeFieldSetFields, Boolean enforceCRUD, Boolean enforceFLS)
{
super(includeFieldSetFields, enforceCRUD, enforceFLS);
}
public List<Contact> selectById(Set<Id> ids);
{
...
}
public with sharing class WithSharing extends ContactsSelector
{
public WithSharing()
{
super(true, true, true);
}
public override List<Contact> selectById(Set<Id> idSet)
{
return super.selectById(idSet);
}
}
public with sharing class WithoutSharing extends ContactsSelector
{
public WithSharing()
{
super(true, false, false);
}
public override List<Contact> selectById(Set<Id> idSet)
{
return super.selectById(idSet);
}
}
}
Metadata
Metadata
Assignees
Labels
No labels