Hi,
I've exported two Advanced Find queries to query queues with inactive mailboxes and unapproved emails within CRM. Now I want to create this same query using LINQ in a solution using the CRM SDK 2015.
I started by exporting the FetchXML queries and then tried converting them to their LINQ equivelant.
Advanced Find queries -
1.Look For: Queues
Select ->
Mailbox(related) ->
Status -> Equals -> Inactive
2.Look For: Queues
Primary Email Status -> Equals -> Pending Approval; Rejected
Fetch XML Queries -
Mailbox:
<?xml version="1.0"?> -<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"> -<entity name="queue"> <attribute name="name"/> <attribute name="emailaddress"/> <attribute name="queueid"/> <order descending="false" attribute="name"/> -<filter type="and"> -<condition attribute="emailrouteraccessapproval" operator="in"> <value>2</value> <value>3</value> </condition> </filter> </entity> </fetch>
Email:
<?xml version="1.0"?> -<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0"> -<entity name="queue"> <attribute name="name"/> <attribute name="emailaddress"/> <attribute name="queueid"/> <order descending="false" attribute="name"/> -<link-entity name="mailbox" alias="ab" to="defaultmailbox" from="mailboxid"> -<filter type="and"> <condition attribute="statecode" value="1" operator="eq"/> </filter> </link-entity> </entity> </fetch>
This is my attempt at each query in LINQ which don't return the same results as the fetch queries -
Unnaproved Email query:
List<Entity> queues = (from q in sourceContext.CreateQuery("queue")
where q.GetAttributeValue("emailrouteraccessapproval").Equals(false)
select q).ToList();Disabled Mailbox query:
List<Entity> queues = (from q in sourceContext.CreateQuery("queue")
where q.GetAttributeValue("defaultmailbox").Equals(false)
select q).ToList();
Does anyone know the correct LINQ conversion for the above two FetchXML queries?