What is best method to get GetItemsWithUniquePermissions count from SharePoint 2013 using client context (CSOM)?
<p>I’m converting Event receiver codes into Remote event receiver using SharePoint 2013 Client context. I need to get list items with unique permissions count to validate while creating new document in certain site collections</p>

<p>It is possible using SharePoint object model </p>

<pre><code>SP.List.GetItemsWithUniquePermissions().Count()
</code></pre>

<p>I written the below logic to get list items with unique permissions count in CSOM but it is throwing timeout exception </p>

<pre><code>var items = list.GetItems(CamlQuery.CreateAllItemsQuery());
            ctx.Load(items, icol =&gt; icol.Include(i =&gt; i.RoleAssignments.Include(ra =&gt; ra.Member), i =&gt; i.DisplayName));
            ctx.ExecuteQuery();
            List&lt;string&gt; uniqitem = new List&lt;string&gt;();
            foreach (var item in items)
            {
                foreach (var assignment in item.RoleAssignments)
                {
                    uniqitem.Add(assignment.Member.Title);
                }
            }
            int itemCount = uniqitem.Distinct().Count();
</code></pre>

<p>Could you please suggest me the right method in CSOM ? Thanks in advance</p>