简体   繁体   中英

dynamics crm 365 plugin apply QueryExpression to custom list of entities

In my plugin, I have a list of entities. I would like to apply the query expression that is passed in the input parameters

QueryExpression query = PluginExecutionContext.InputParameters["Query"];

to a custom list of type entity.

List<Entity> myList;

The entities in the list match the same attributes as the entities used in the plugin context. Is there a way to apply a QueryExpression to a list of entities, or convert a QueryExpression to linq?

QueryExpression is really just a wrapper around FetchXML, which is just an XML schema for queries in Dynamics CRM. If you want to pass in a query as a parameter to a plugin, you could set up an custom entity call "query" or something to that effect and add a field of type textarea to that custom entity called "fetchxml". Then set up the input parameter of your plugin to accept a record of that custom entity instead of a text parameter. this has the added benefit of allowing you to more easily edit the input parameters of the plugin.

Of course, you could always just put the raw fetchXML into the parameter as text, but I can tell you from experience that this will come back to bite you as it is extremely hard to maintain because any changes elsewhere in the system could completely trash your plugin.

If you want to know more about how to get the fetchXML for a certain query or have any other questions, just shoot me a comment.

Is there a way to apply a QueryExpression to a list of entities

Answer is No.

QueryExpression & FetchXML is native of Dynamics CRM, it can be used against CRM service (Database) only. I assume this plugin is on Retrieve message and you are trying to use the system's query expression from that Retrieve service call against your own dataset of entity ( List<Entity> ). But why?

, or convert a QueryExpression to linq?

No. I know the reverse is possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM