1

So, I'm using CRM 2011. In order to improve performance I have started using the ExecuteMultipleRequest. It works fine when creating many records at once. Great! The issue I have is that right after I have done a

context.Execute(myMultipleRequest);

and gotten a valid response with id's back, if I then do a

context.myEntitiesSet.Where(x => x.Name == "foo")

(basically query the objects just created) I don't get valid objects back, meaning their id's are empty (Guid.Empty).

So, it seems I have to choose to either use:

  • use context.Create(), context.Update(), context.Where(...), et.c. or
  • use context.Execute(multiple) and context.RetrieveMultiple()

There doesn't seem to be a middle ground, as the Context doesn't seem to update which entities it is tracking when I'm using the ExecuteMultipleRequest. That is my basic problem. I can create objects just fine, but if I want to query them I can't use a linq query on the context, I must then use RetrieveMultiple.

Have I gotten this backwards, or is this well known when using CRM? I am an experienced developer, but relatively new to CRM.

Should I have to call context.AttachObject() myself for all newly created entities when using ExecuteMultipleRequest?

Any help would be appreciated. Oh, and I'm using early bound objects.

Matt
  • 4,656
  • 1
  • 22
  • 32
Henrik Oscarsson
  • 147
  • 1
  • 11

1 Answers1

1

I don't believe the CrmLinqProvider has been extended to handle your instance. The ExecuteMultipleRequest returns an ExecuteMultipleResponse object that contains the results of each request. You'll need to loop through this to determine the ids, and update them yourself.

Daryl
  • 18,592
  • 9
  • 78
  • 145