Skip to content

Instantly share code, notes, and snippets.

@gashupl
Created May 27, 2019 17:55
Show Gist options
  • Save gashupl/0ebb655f8905c7249b527cb3d8d905e7 to your computer and use it in GitHub Desktop.
Save gashupl/0ebb655f8905c7249b527cb3d8d905e7 to your computer and use it in GitHub Desktop.
public class OpportunityRepository : IOpportunityRepository
{
protected Dyn365ServiceContext serviceContext;
public OpportunityRepository(IOrganizationService service)
{
this.serviceContext = new Dyn365ServiceContext(service);
}
public Opportunity GetById(Guid id)
{
return this.serviceContext.OpportunitySet.FirstOrDefault(o => o.Id == id);
}
public void Create(Opportunity opportunity)
{
this.serviceContext.AddObject(opportunity);
}
public void SaveChanges()
{
this.serviceContext.SaveChanges();
}
public void Dispose()
{
this.serviceContext.Dispose();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment