Skip to content

Commit

Permalink
Change bulk operations implementation to use internal operations that…
Browse files Browse the repository at this point in the history
… do not trigger pipeline requests, these will be moved to the plugings project and pipeline simulation to make sure they trigger in the same order as the platform. DynamicsValue/fake-xrm-easy#122
  • Loading branch information
jordimontana82 committed May 24, 2024
1 parent bc67cdd commit d879715
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public OrganizationResponse Execute(OrganizationRequest request, IXrmFakedContex

foreach (var record in records)
{
var id = service.Create(record);
var id = ctx.CreateEntity(record);
createdIds.Add(id);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public OrganizationResponse Execute(OrganizationRequest request, IXrmFakedContex

foreach (var record in records)
{
service.Update(record);
ctx.UpdateEntity(record);
}

return new UpdateMultipleResponse()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,23 @@ public OrganizationResponse Execute(OrganizationRequest request, IXrmFakedContex

var service = ctx.GetOrganizationService();

foreach (var record in records)
foreach (var record in records)
{
var response = service.Execute(new UpsertRequest() { Target = record }) as UpsertResponse;
UpsertResponse response = null;
if (ctx.ContainsEntity(record.LogicalName, record.Id))
{
ctx.UpdateEntity(record);
response = new UpsertResponse();
response.Results.Add("RecordCreated", false);
response.Results.Add("Target", new EntityReference(record.LogicalName, record.Id));
}
else
{
var id = ctx.CreateEntity(record);
response = new UpsertResponse();
response.Results.Add("RecordCreated", true);
response.Results.Add("Target", new EntityReference(record.LogicalName, id));
}
results.Add(response);
}

Expand Down

0 comments on commit d879715

Please sign in to comment.