This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE dbo.SdkMessageFilterBase | |
SET [IsCustomProcessingStepAllowed] = 1 | |
WHERE PrimaryObjectTypeCode = (SELECT DISTINCT ObjectTypeCode FROM Entity WHERE Name LIKE 'SystemUser') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RepositoryFactory | |
{ | |
private IOrganizationService service; | |
public RepositoryFactory(IOrganizationService service) | |
{ | |
this.service = service; | |
} | |
public T Get<E, T>() where E : Entity where T : RepositoryBase<E> | |
{ | |
var repository = (T)Activator.CreateInstance(typeof(T), this.service); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var orgService = serviceFactory.CreateOrganizationService(pluginExecutionContext.UserId); | |
var factory = new RepositoryFactory(orgService); | |
var opportunityRepo = factory.Get<Opportunity, OpportunityRepository>(); | |
var data = opportunityRepo.GetSomeData(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RepositoryFactory | |
{ | |
private IOrganizationService service; | |
public RepositoryFactory(IOrganizationService service) | |
{ | |
this.service = service; | |
} | |
public T Get<E, T>() where E : Entity where T: RepositoryBase<E>, new() | |
{ | |
var repository = new T(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void Execute(IPluginExecutionContext pluginExecutionContext, IOrganizationServiceFactory serviceFactory, ITracingService tracingService) | |
{ | |
var orgService = serviceFactory.CreateOrganizationService(pluginExecutionContext.UserId); | |
var factory = new RepositoryFactory(orgService); | |
var opportunityRepo = factory.Get(); | |
var data = opportunityRepo.GetSomeData(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RepositoryFactory | |
{ | |
private IOrganizationService service | |
public RepositoryFactory(IOrganizationService service) | |
{ | |
this.service = service; | |
} | |
public OpportunityRepository Get() | |
{ | |
return new OpportunityRepository(this.service); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public override void Execute(IPluginExecutionContext pluginExecutionContext, IOrganizationServiceFactory serviceFactory, ITracingService tracingService) | |
{ | |
var orgService = serviceFactory.CreateOrganizationService(pluginExecutionContext.UserId); | |
var opportunityRepo = new OpportunityRepository(orgService); | |
var data = opportunityRepo.GetSomeData(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IOpportunityRepository : IRepository<Opportunity> | |
{ | |
List<Opportunity> GetByAccountId(Guid id); | |
} | |
public class OpportunityRepository : RepositoryBase<Opportunity>, IOpportunityRepository | |
{ | |
public OpportunityRepository(IOrganizationService service) : base(service) | |
{ | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class RepositoryBase<T> : IRepository<T> where T : Entity | |
{ | |
protected Dyn365ServiceContext ServiceContext; | |
protected IOrganizationService OrgService; | |
public RepositoryBase(IOrganizationService service) | |
{ | |
this.OrgService = service; | |
this.ServiceContext = new Dyn365ServiceContext(service); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IRepository<T> where T: Entity | |
{ | |
T GetById(Guid id); | |
void Create(T entity); | |
void SaveChanges(); | |
void Dispose(); | |
} |
NewerOlder