web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

LINQ Query in Dynamics 365 Isolated Plugin (Sandbox)

(1) ShareShare
ReportReport
Posted on by 30

I have a plug-in that is deployed with an isolation mode of sandbox. The uses an instance of the OrganizationServiceContext class generated by CrmSvcUtil.exe to perform LINQ queries, e.g. MyOrganizationServiceContextInstance.SystemUserSet.FirstOrDefault(x => x.Id == PluginExecutionContext.UserId) to get the SystemUser running the plug-in. Of course, SystemUserSet is underlyingly CreateQuery<SystemUser>(). I am getting an error "The specified type <MyEarlyBoundNamespace>.SystemUser is not a known entity type." I have added the ProxyTypesAssembly Attribute to the Assembly.cs file. I have seen one or two posts that say you can't execute LINQ queries in this fashion in a sandboxed plugin and one or two posts that say you can. Can someone please confirm (or deny) whether or not it is possible to execute LINQ queries in a sandboxed plug-in?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Johan Kustner Profile Picture
    30 on at

    I am using the new Beta 1 version of the new Developer Toolkit for Dynamics 365 that Microsoft just release on 11-11-2016 and updated on 22-11-2016.

    I modified the PluginBase.cs class file and changed the internal LocalPluginContext constructor to include this code. However, there is a problem in instantiating an OrganizationServiceContext class instance and the SystemUser class instance here, causing the exception to be thrown. I therefore moved the code directly into the plugin's Execute method. But there are still problems.

    It just looks like there is problems using LINQ with the OrganizationServiceContext in Sandbox Isolation Mode. It would seem as if the CreateQuery<EntityType>() method is executed in a different application domain or a different thread and that domain or thread is not passed the details of the EntityType, in my case SystemUser.

    I suspect then that it is not possible to run LINQ in an isolated (sandbox) plug-in. However, I wonder if there is a way to force the LINQ to not be lazy loading and if that will make a difference.

    But for now, it would seem to me that it is not possible. It would be great if someone from Microsoft can confirm my findings.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans