Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do a LINQ query for count of entity whose owner == current user?

I'm using Microsoft Dynamics CRM 2011 and ADX Studios. On one of the pages I'm trying to make a widget that will display the user's number of current leads. I want to do a LINQ query that selects the count of lead where the owner of the lead entity in the CRM database is equal to the current user. I'm new to LINQ, so I'm still trying to get a grasp on the semantics of the queries. Below I have my code so far which pulls in all leads. I'm not quite sure how to work in the "where" clause that checks to see if the owner id equals that of the current user.

count = context.LeadSet.ToList().Count();
like image 666
Matt Healey Avatar asked Dec 05 '25 03:12

Matt Healey


1 Answers

See this answer:

Linq to CRM doesn't support any aggregate expressions, so it would be better from a performance standpoint to use Fetch XML.

like image 156
Daryl Avatar answered Dec 07 '25 15:12

Daryl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!