<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>CAML Joins, CAMLEX and the 5,000 Item Wall on Jeppe Spanggaard - Software Developer | .NET, Azure &amp; Microsoft 365</title><link>https://jeppe-spanggaard.dk/tags/caml/</link><description>Recent content in CAML Joins, CAMLEX and the 5,000 Item Wall on Jeppe Spanggaard - Software Developer | .NET, Azure &amp; Microsoft 365</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 16 Aug 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://jeppe-spanggaard.dk/tags/caml/index.xml" rel="self" type="application/rss+xml"/><item><title>List View Threshold: What Still Works at 10,000 Items</title><link>https://jeppe-spanggaard.dk/blogs/list-view-threshold-what-still-works/</link><pubDate>Sun, 16 Aug 2026 00:00:00 +0000</pubDate><guid>https://jeppe-spanggaard.dk/blogs/list-view-threshold-what-still-works/</guid><description>Learn which SharePoint queries survive the 5,000 item list view threshold, with CAML joins, CSOM, REST, Graph and $batch measured on a 10,000 item list.</description><content:encoded><![CDATA[<p>I&rsquo;ve lost count of how many times I&rsquo;ve hit this. A list quietly grows past 200,000 items, somebody asks for a filtered view of it, and the code that has worked for two years answers with this instead:</p>
<pre tabindex="0"><code>Microsoft.SharePoint.Client.ServerException: The attempted operation is
prohibited because it exceeds the list view threshold.
</code></pre><p>The code didn&rsquo;t change. It never does.</p>
<p>CSOM has an escape hatch for this, <code>AllowIncrementalResults</code>, and it gets <a href="https://jeppe-spanggaard.dk/blogs/caml-allowincrementalresults-list-view-threshold/">a post of its own</a>. What I could never answer was the obvious follow-up. Is CSOM the only place with an answer? Every time I&rsquo;d needed to filter past the threshold I&rsquo;d ended up back in CSOM, but I&rsquo;d never actually gone and checked what REST and Graph do. Saying &ldquo;I don&rsquo;t know&rdquo; for two years is a long time.</p>
<p>So I took the harness from <a href="https://jeppe-spanggaard.dk/blogs/caml-joins-across-lists/">the CAML joins benchmark</a>, seeded a second four-list chain at 10,000 items per list, and ran everything again. Ten thousand is not two hundred thousand, but it&rsquo;s twice the threshold, which is where the behaviour changes.</p>
<h2 id="what-actually-breaks-at-the-sharepoint-list-view-threshold">What actually breaks at the SharePoint list view threshold?</h2>
<p>Not reading. I can still pull all 10,000 rows out of any of these APIs, and it costs two requests. What breaks is filtering: the moment a <code>&lt;Where&gt;</code> or a <code>$filter</code> touches a column SharePoint hasn&rsquo;t indexed, the query is refused, and it&rsquo;s refused even when the answer would be ten rows. The threshold is about the scan, not the result set. That single sentence explains almost everything below.</p>
<h2 id="reading-was-never-the-problem">Reading Was Never the Problem</h2>
<p>The first thing I measured is the thing nobody worries about, and it turns out to be fine:</p>
<table>
  <thead>
      <tr>
          <th>Reading all 10,000 rows</th>
          <th style="text-align: right">Requests</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CAML join over CSOM, <code>RowLimit</code> paging</td>
          <td style="text-align: right">2</td>
      </tr>
      <tr>
          <td>SharePoint REST, <code>$top=5000</code> plus <code>odata.nextLink</code></td>
          <td style="text-align: right">2</td>
      </tr>
      <tr>
          <td>Graph, <code>$top=5000</code> plus <code>@odata.nextLink</code></td>
          <td style="text-align: right">2</td>
      </tr>
  </tbody>
</table>
<p>Two requests each, because 10,000 rows is two pages of 5,000. An unfiltered read past the threshold is allowed on all three. If your job is &ldquo;give me the whole list&rdquo;, the threshold barely exists.</p>
<p>That&rsquo;s worth saying plainly because the error message sends people hunting for the wrong fix. You don&rsquo;t need to restructure your list to read it.</p>
<h2 id="the-flag-that-shouldnt-work-and-does">The Flag That Shouldn&rsquo;t Work, and Does</h2>
<p>Here&rsquo;s the one I got wrong, and I was confident about it.</p>
<p>The most useful thing a CAML join does is let you filter on a column that lives several lists away, by projecting it and putting the <code>&lt;Where&gt;</code> on the projection. But a projected field is not a column on the list. It doesn&rsquo;t exist there, so it cannot be indexed. And the documented rule for <code>AllowIncrementalResults</code> is that the fields you filter and sort on still have to be indexed.</p>
<p>I was sure that made the technique impossible past 5,000 items. I wrote the probe expecting to have to publish a correction.</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#66d9ef">var</span> query = <span style="color:#66d9ef">new</span> CamlQuery
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    ViewXml = viewXml,               <span style="color:#75715e">// &lt;Joins&gt;, &lt;ProjectedFields&gt;, &lt;Where&gt; on customerNo</span>
</span></span><span style="display:flex;"><span>    AllowIncrementalResults = <span style="color:#66d9ef">true</span>,
</span></span><span style="display:flex;"><span>};
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> all = <span style="color:#66d9ef">new</span> List&lt;ListItem&gt;();
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">do</span>
</span></span><span style="display:flex;"><span>{
</span></span><span style="display:flex;"><span>    <span style="color:#66d9ef">var</span> items = list.GetItems(query);
</span></span><span style="display:flex;"><span>    context.Load(items);
</span></span><span style="display:flex;"><span>    context.Load(items, i =&gt; i.ListItemCollectionPosition);
</span></span><span style="display:flex;"><span>    context.ExecuteQuery();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>    all.AddRange(items);
</span></span><span style="display:flex;"><span>    query.ListItemCollectionPosition = items.ListItemCollectionPosition;
</span></span><span style="display:flex;"><span>}
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">while</span> (query.ListItemCollectionPosition <span style="color:#66d9ef">is</span> not <span style="color:#66d9ef">null</span>);
</span></span></code></pre></div><p><strong>What&rsquo;s happening here?</strong></p>
<ol>
<li>Without <code>AllowIncrementalResults</code>, this exact query is refused: <code>SPQueryThrottledException</code>, straight away, no rows.</li>
<li>With it, the same query returns all 5,000 matching rows in two requests. The filter is on <code>customerNo</code>, which is projected from a list two hops away and cannot be indexed anywhere.</li>
<li><code>ListItemCollectionPosition</code> is the cursor and it is not optional. A <code>&lt;RowLimit&gt;</code> on its own doesn&rsquo;t page, it truncates, and truncation is the failure mode you don&rsquo;t notice.</li>
<li>You need both properties loaded. <code>context.Load(items)</code> alone won&rsquo;t populate the position on every code path, and a null cursor looks exactly like a finished result set.</li>
</ol>
<p>So the join survives the threshold. My best guess at why is that the projection is resolved after the join rather than as a scan predicate, but that&rsquo;s inference, not something I can prove from the outside. What I can say is that it returned the right 5,000 rows, ten times in a row.</p>
<p>Then I checked whether the depth matters, because it easily could have. Everything above filters on a value two lists away, which is the shape I&rsquo;ve written about before. So I moved the query one list further back and made the projection travel three joins instead of two:</p>
<table>
  <thead>
      <tr>
          <th>Projection travels</th>
          <th>Without the flag</th>
          <th>With the flag</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>Two joins</td>
          <td><code>SPQueryThrottledException</code></td>
          <td>5,000 rows, 2 requests</td>
      </tr>
      <tr>
          <td>Three joins</td>
          <td><code>SPQueryThrottledException</code></td>
          <td>5,000 rows, 2 requests</td>
      </tr>
  </tbody>
</table>
<p>Identical, right down to the request count. Whatever the flag is doing, it isn&rsquo;t running out of road at the second hop, and a filter three lists from the one you&rsquo;re querying is as viable past the threshold as a filter one list away.</p>
<h2 id="three-apis-three-different-refusals">Three APIs, Three Different Refusals</h2>
<p>Filter on a column that genuinely isn&rsquo;t indexed, and all three refuse. How they refuse is where they differ.</p>
<table>
  <thead>
      <tr>
          <th>API</th>
          <th>Status</th>
          <th>What you get</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CSOM</td>
          <td>exception</td>
          <td><code>SPQueryThrottledException</code></td>
      </tr>
      <tr>
          <td>SharePoint REST</td>
          <td><strong><code>500</code></strong></td>
          <td>the same exception, wrapped in an OData error body</td>
      </tr>
      <tr>
          <td>Graph</td>
          <td><strong><code>400</code></strong></td>
          <td>a message that names the fix</td>
      </tr>
  </tbody>
</table>
<p>Graph wins this one, and it isn&rsquo;t close:</p>
<pre tabindex="0"><code>Field &#39;Title&#39; cannot be referenced in filter or orderby as it is not
indexed. Provide the &#39;Prefer: HonorNonIndexedQueriesWarningMayFailRandomly&#39;
header to allow this, but be warned that it may fail randomly.
</code></pre><p>Add the header and the same request returns <code>200</code>. Read the header&rsquo;s name again before you reach for it, though. Somebody at Microsoft went to the trouble of putting &ldquo;MayFailRandomly&rdquo; in an API contract, and that is not the kind of thing you build a nightly job on.</p>
<p>REST answering <code>500</code> for this is the one that annoys me. Filtering an unindexed column on a large list is a completely predictable, documented, business-as-usual refusal. It is not an internal server error.</p>
<h2 id="the-rest-trick-that-only-works-under-5000">The REST Trick That Only Works Under 5,000</h2>
<p>In the previous post I found something I didn&rsquo;t expect: SharePoint REST will let you filter on an expanded lookup&rsquo;s column, even one that isn&rsquo;t the lookup&rsquo;s <code>ShowField</code>.</p>
<pre tabindex="0"><code>$filter=CustomerLookUp/customerNo eq &#39;C-NARROW&#39;&amp;$expand=CustomerLookUp
</code></pre><p>At 1,000 items that returns <code>200</code> and it&rsquo;s the single thing that got the OData route down to two requests. At 10,000 items it returns <code>500</code>, in every scenario I threw at it, along with the batched version of the same call.</p>
<p>So it&rsquo;s a sub-threshold trick. It works beautifully right up until the list is big enough for it to matter, which is a fair description of a lot of SharePoint behaviour. If you have built anything on that shape, it has an expiry date measured in rows.</p>
<h2 id="the-one-that-lies-to-you">The One That Lies to You</h2>
<p><code>RenderListDataAsStream</code> is how you run a CAML join over REST, and in the last post it came through with the projected columns intact. Past the threshold it does something worse than failing.</p>
<p>Asked for 100 matching rows out of 10,000, it returned <strong>47</strong>. Asked for 5,000, it returned 2,504. One request, <code>200 OK</code>, no error, no <code>NextHref</code> to follow, no indication that anything is missing. It stops when the scan window closes and hands you what it found so far as though that were the answer.</p>
<p>A truncated result with a <code>200</code> on it is the worst outcome in this whole post. Everything else either works or tells you it didn&rsquo;t.</p>
<h2 id="what-it-costs-in-memory">What It Costs in Memory</h2>
<p>This is the part I hadn&rsquo;t measured before, and it&rsquo;s the strongest argument in the post. Below, allocated managed bytes while answering the same question: <strong>100 matching rows out of 10,000</strong>.</p>
<table>
  <thead>
      <tr>
          <th>Approach</th>
          <th>Filter</th>
          <th style="text-align: right">Allocated</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CAML join, CSOM</td>
          <td>server</td>
          <td style="text-align: right"><strong>1.4 MB</strong></td>
      </tr>
      <tr>
          <td>CSOM per list, reverse</td>
          <td>server</td>
          <td style="text-align: right">2.3 MB</td>
      </tr>
      <tr>
          <td>Graph, reverse</td>
          <td>server</td>
          <td style="text-align: right">2.6 MB</td>
      </tr>
      <tr>
          <td>Graph <code>$batch</code>, reverse</td>
          <td>server</td>
          <td style="text-align: right">3.1 MB</td>
      </tr>
      <tr>
          <td>SharePoint REST, forward</td>
          <td>client</td>
          <td style="text-align: right">11.5 MB</td>
      </tr>
      <tr>
          <td>SharePoint REST <code>$batch</code>, forward</td>
          <td>client</td>
          <td style="text-align: right">16.9 MB</td>
      </tr>
      <tr>
          <td>Graph, forward</td>
          <td>client</td>
          <td style="text-align: right">50.9 MB</td>
      </tr>
      <tr>
          <td>Graph <code>$batch</code>, forward</td>
          <td>client</td>
          <td style="text-align: right">55.6 MB</td>
      </tr>
      <tr>
          <td>CSOM batched</td>
          <td>client</td>
          <td style="text-align: right">188.0 MB</td>
      </tr>
      <tr>
          <td>CSOM per list, forward</td>
          <td>client</td>
          <td style="text-align: right"><strong>200.0 MB</strong></td>
      </tr>
  </tbody>
</table>
<p>One hundred rows. Two hundred megabytes.</p>
<p>The split is exactly the <code>Filter</code> column. Every approach that filters on the server materialises about a hundred rows. Every approach that filters in C# has to pull the whole list into memory first, then throw away 99% of it, and at 10,000 items that is 200 MB of allocation to produce 100 objects you keep. Your production lists are twenty times bigger than my test list.</p>
<p>Two things surprised me here. Allocation does not rank the same as bytes on the wire: CSOM allocates roughly eleven times its payload because a <code>ListItem</code> is a heavy object with a field dictionary attached, so 17 MB of response becomes 200 MB of garbage. And the join is not the memory winner when you ask for <em>everything</em>, only when you ask for <em>some</em>. Unfiltered, lean OData that fetches nothing but lookup ids allocates 17 MB against the join&rsquo;s 105 MB, because the join is honestly returning full rows and OData is returning integers.</p>
<h2 id="the-whole-field-at-10000-items">The Whole Field at 10,000 Items</h2>
<p>Filtering to 5,000 rows of 10,000, entering at the order tasks list, two hops to the customer:</p>
<table>
  <thead>
      <tr>
          <th>Approach</th>
          <th>Filter</th>
          <th style="text-align: right">Requests</th>
          <th style="text-align: right">Queries</th>
          <th style="text-align: right">Median</th>
          <th style="text-align: right">Allocated</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CAML join, CSOM</td>
          <td>server</td>
          <td style="text-align: right"><strong>2</strong></td>
          <td style="text-align: right"><strong>2</strong></td>
          <td style="text-align: right"><strong>1,096 ms</strong></td>
          <td style="text-align: right">52.7 MB</td>
      </tr>
      <tr>
          <td>SharePoint REST <code>$batch</code></td>
          <td>client</td>
          <td style="text-align: right">2</td>
          <td style="text-align: right">5</td>
          <td style="text-align: right">1,752 ms</td>
          <td style="text-align: right">17.0 MB</td>
      </tr>
      <tr>
          <td>SharePoint REST, forward</td>
          <td>client</td>
          <td style="text-align: right">5</td>
          <td style="text-align: right">5</td>
          <td style="text-align: right">2,021 ms</td>
          <td style="text-align: right">12.2 MB</td>
      </tr>
      <tr>
          <td>CSOM per list, reverse</td>
          <td>server</td>
          <td style="text-align: right">12</td>
          <td style="text-align: right">12</td>
          <td style="text-align: right">2,870 ms</td>
          <td style="text-align: right">97.7 MB</td>
      </tr>
      <tr>
          <td>CSOM batched</td>
          <td>client</td>
          <td style="text-align: right">2</td>
          <td style="text-align: right">5</td>
          <td style="text-align: right">3,110 ms</td>
          <td style="text-align: right">188.5 MB</td>
      </tr>
      <tr>
          <td>Graph <code>$batch</code>, reverse</td>
          <td>server</td>
          <td style="text-align: right">5</td>
          <td style="text-align: right">62</td>
          <td style="text-align: right">3,311 ms</td>
          <td style="text-align: right">162.9 MB</td>
      </tr>
      <tr>
          <td>CSOM per list, forward</td>
          <td>client</td>
          <td style="text-align: right">23</td>
          <td style="text-align: right">23</td>
          <td style="text-align: right">5,157 ms</td>
          <td style="text-align: right">200.5 MB</td>
      </tr>
      <tr>
          <td>Graph <code>$batch</code>, forward</td>
          <td>client</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">6,369 ms</td>
          <td style="text-align: right">56.0 MB</td>
      </tr>
      <tr>
          <td>Graph, forward</td>
          <td>client</td>
          <td style="text-align: right">5</td>
          <td style="text-align: right">5</td>
          <td style="text-align: right">9,052 ms</td>
          <td style="text-align: right">52.9 MB</td>
      </tr>
      <tr>
          <td>Graph, reverse</td>
          <td>server</td>
          <td style="text-align: right">62</td>
          <td style="text-align: right">62</td>
          <td style="text-align: right">13,970 ms</td>
          <td style="text-align: right">140.0 MB</td>
      </tr>
      <tr>
          <td>CAML join over REST</td>
          <td>-</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">wrong answer</td>
          <td style="text-align: right">-</td>
      </tr>
      <tr>
          <td>SharePoint REST, reverse</td>
          <td>-</td>
          <td style="text-align: right">-</td>
          <td style="text-align: right">-</td>
          <td style="text-align: right"><code>HTTP 500</code></td>
          <td style="text-align: right">-</td>
      </tr>
      <tr>
          <td>SharePoint REST <code>$batch</code>, reverse</td>
          <td>-</td>
          <td style="text-align: right">-</td>
          <td style="text-align: right">-</td>
          <td style="text-align: right"><code>HTTP 500</code></td>
          <td style="text-align: right">-</td>
      </tr>
  </tbody>
</table>
<p>The join is still first, and at 10,000 items it is now first by a wider margin than at 1,000, because everything else has to page and it only has to page twice.</p>
<p>Note what happened to Graph&rsquo;s reverse walk: 62 requests. The or-chains that fitted in a handful of calls at 1,000 items become sixty-two at 10,000, and batching turns 62 round trips into 5 while leaving all 62 queries exactly where they were.</p>
<h2 id="gotchas">Gotchas</h2>
<ul>
<li><strong>The exception message is localised.</strong> My tenant answers in Danish: <code>Den forsøgte handling er ikke tilladt, fordi den overskrider grænsen for listevisning</code>. My first probe matched on the string &ldquo;list view threshold&rdquo; and therefore never detected a single hit. Match on <code>ex.ServerErrorTypeName == &quot;Microsoft.SharePoint.SPQueryThrottledException&quot;</code> instead. Any retry logic or alerting built on the message text is broken in every tenant that isn&rsquo;t English.</li>
<li><strong><code>&lt;RowLimit&gt;</code> without a cursor is a truncation, not a page.</strong> This is how you get a wrong answer with no error. One of my own arms returned 47 rows out of 100 because it read the first 5,000 items of a 10,000 item list and then filtered what it happened to have.</li>
<li><strong>Batching collapses queries, never pages.</strong> A cursor only exists once the previous response has arrived, so a batch can carry every list&rsquo;s page one and then has to go again for page two. That&rsquo;s true of CSOM&rsquo;s <code>ExecuteQuery</code>, of SharePoint&rsquo;s <code>$batch</code>, and of Graph&rsquo;s. Graph&rsquo;s docs suggest batching as a way around URL length limits; I measured the same 91 clause ceiling inside a batch as outside it, so that particular workaround doesn&rsquo;t apply here.</li>
<li><strong><code>&lt;In&gt;</code> past 60 values is fine, and I&rsquo;m one of the people who told you otherwise.</strong> I repeated the 60-value claim in the joins post and cited the archived 2013 article it comes from. On 10,000 items with an indexed lookup column I ran 50, 60, 61, 100 and 500 values, and every one of them returned. The 500-value hard cap is real: 501 still throws <code>Value does not fall within the expected range</code>. It&rsquo;s the 60 that I can&rsquo;t reproduce.</li>
<li><strong>The ceiling moves.</strong> One reverse-traversal arm hit the threshold in one scenario and sailed through the same shape of query in another. Large list throttling is a service-side feature with a time-of-day component, so &ldquo;it worked this morning&rdquo; is not a test result.</li>
<li><strong>Your own tooling will hit this too.</strong> The setup step of my harness crashed while verifying the data it had just seeded, because it ran an <code>&lt;IsNull&gt;</code> check with <code>&lt;RowLimit&gt;10&lt;/RowLimit&gt;</code>. Ten rows requested, still refused. I had written that check myself and still didn&rsquo;t see it coming.</li>
</ul>
<h2 id="wrapping-up">Wrapping Up</h2>
<p>Reading a big list is easy on every API. Filtering it is where they separate, and they separate hard: CSOM throws something you can catch, REST throws a <code>500</code>, Graph throws a <code>400</code> with instructions, and <code>RenderListDataAsStream</code> hands you a partial answer with a <code>200</code> on it.</p>
<p>The advice from the previous post survives the threshold, with one line added. Make SharePoint do the join, set <code>AllowIncrementalResults = true</code>, and page with the cursor. It stays the fastest correct answer at 10,000 items, and it&rsquo;s the only approach that filters server-side without resolving the ids yourself first, which past the threshold has stopped being a performance question and become a memory one.</p>
<p>Everything else is holding your whole list in RAM to find a hundred rows in it, and it is doing that whether or not anyone measured it.</p>
]]></content:encoded></item><item><title>CAML Joins Across Lists: One Query Instead of Four</title><link>https://jeppe-spanggaard.dk/blogs/caml-joins-across-lists/</link><pubDate>Sat, 15 Aug 2026 00:00:00 +0000</pubDate><guid>https://jeppe-spanggaard.dk/blogs/caml-joins-across-lists/</guid><description>Learn how a CAML join across SharePoint lists linked by lookup columns compares with separate queries, OData expands and Graph, measured on the same data.</description><content:encoded><![CDATA[<p>I&rsquo;ve been telling people to use CAML joins since 2025. I wrote <a href="https://jeppe-spanggaard.dk/blogs/joining-multiple-lists-csom-caml/">a whole post about it</a>. I put it in <a href="https://jeppe-spanggaard.dk/blogs/csom-vs-sharepoint-rest-vs-graph/">my pick-one playbook</a> as a reason CSOM still owns list items.</p>
<p>And I had never measured it.</p>
<p>Not properly. Never all the reasonable ways of fetching the same data, against the same lists, on the same day. It&rsquo;s always been case by case: this feels like the better solution here, that one felt slow last time. In my head, one call instead of four <em>has</em> to be faster, and that was enough.</p>
<p>That&rsquo;s not a benchmark. That&rsquo;s a hunch I&rsquo;d been repeating with confidence.</p>
<p>So I built the comparison I should have built a year ago. It moved my numbers, and it also corrected something I&rsquo;d been saying wrong for a year.</p>
<h2 id="is-a-caml-join-actually-faster-than-four-separate-queries">Is a CAML join actually faster than four separate queries?</h2>
<p>Yes, and by more than I expected. Fetching 1,000 rows across a three-hop lookup chain, the CAML join needed <strong>1 HTTP request and about 254 ms</strong>. The same rows through four separate CSOM queries took <strong>6 requests and 1,192 ms</strong>, OData expands over SharePoint REST took <strong>4 requests and 548 ms</strong>, and Microsoft Graph took <strong>4 requests and 1,655 ms</strong>. The join wasn&rsquo;t just fewer calls, it was 4.7x faster than the four-query CSOM version and 6.5x faster than Graph. The closest anything got was SharePoint REST with <code>$batch</code>, at 355 ms, and that one deserves its own paragraph rather than a footnote.</p>
<h2 id="same-rows-eight-ways">Same Rows, Eight Ways</h2>
<p>Four lists, each pointing at the next through a lookup column:</p>
<pre tabindex="0"><code>Main -&gt; OrderTasks -&gt; Orders -&gt; Customers
</code></pre><p>Every approach has to return the same thing for each of the 1,000 items in the main list: its id, its title, and the <code>customerNo</code> and <code>customerName</code> from a customer sitting three hops away.</p>
<p>The join version, built with <a href="https://github.com/sadomovalex/camlex">CAMLEX</a>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#66d9ef">const</span> <span style="color:#66d9ef">string</span> OrderTasks = <span style="color:#e6db74">&#34;ordertasks&#34;</span>, Orders = <span style="color:#e6db74">&#34;orders&#34;</span>, Customers = <span style="color:#e6db74">&#34;customers&#34;</span>;
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>CamlexNET.Interfaces.IQuery query = Camlex.Query()
</span></span><span style="display:flex;"><span>    .LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;OrderTaskLookUp&#34;</span>].ForeignList(OrderTasks))
</span></span><span style="display:flex;"><span>    .LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;OrderDetailLookUp&#34;</span>].PrimaryList(OrderTasks).ForeignList(Orders))
</span></span><span style="display:flex;"><span>    .LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;CustomerLookUp&#34;</span>].PrimaryList(Orders).ForeignList(Customers))
</span></span><span style="display:flex;"><span>    .ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;customerNo&#34;</span>].List(Customers).ShowField(<span style="color:#e6db74">&#34;customerNo&#34;</span>))
</span></span><span style="display:flex;"><span>    .ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;customerName&#34;</span>].List(Customers).ShowField(<span style="color:#e6db74">&#34;customerName&#34;</span>))
</span></span><span style="display:flex;"><span>    .ViewFields([<span style="color:#e6db74">&#34;ID&#34;</span>, <span style="color:#e6db74">&#34;Title&#34;</span>, <span style="color:#e6db74">&#34;customerNo&#34;</span>, <span style="color:#e6db74">&#34;customerName&#34;</span>]);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> items = mainList.GetItems(query.ToCamlQuery());
</span></span><span style="display:flex;"><span>context.Load(items);
</span></span><span style="display:flex;"><span>context.ExecuteQuery();
</span></span></code></pre></div><p><strong>What&rsquo;s happening here?</strong></p>
<ol>
<li>Each <code>LeftJoin</code> walks one lookup hop. <code>PrimaryList</code> is the list you&rsquo;re coming <em>from</em>, <code>ForeignList</code> the one you&rsquo;re going <em>to</em>, which is what lets hops two and three start somewhere other than the main list. Those arguments are <strong>aliases you invent</strong>, not list ids: they&rsquo;re <code>string</code>, and the compiler will tell you so (<code>cannot convert from 'System.Guid' to 'string'</code>) if you try otherwise. SharePoint resolves the actual list from the lookup column&rsquo;s own configuration, so <code>&quot;orders&quot;</code> works exactly as well as a GUID. I checked, because I&rsquo;d been passing GUIDs for a year without knowing they were only ever labels.</li>
<li><code>ProjectedField</code> pulls a column out of a joined list and gives it a name you can use as if it lived on the main list.</li>
<li><code>ViewFields</code> is not optional, and this is the part I&rsquo;d been getting away with rather than getting right. A projected field that isn&rsquo;t listed there comes back absent, with no error. Same query, same joins, one <code>&lt;FieldRef&gt;</code> removed: the column is simply not on the item.</li>
<li><code>ToCamlQuery()</code>, not <code>ToString()</code>. Bare <code>ToString()</code> gives you <code>&lt;Joins&gt;</code> and <code>&lt;ProjectedFields&gt;</code> as two sibling roots with no <code>&lt;View&gt;</code> around them, which isn&rsquo;t a well-formed document at all. SharePoint accepts it anyway and hands back all 1,000 rows, minus the projected columns, because there&rsquo;s no <code>&lt;ViewFields&gt;</code> in a fragment. A silent wrong answer is worse than an exception, and I&rsquo;d shipped that line.</li>
<li>The values come back as <code>FieldLookupValue</code>, not <code>string</code>, even when the source column is plain text. The text is in <code>.LookupValue</code>, which trips people up the first time.</li>
</ol>
<p>Every approach below returned an identical result set once normalised, checked by hashing the rows and comparing against a hash computed from the seed data. The wire shapes differ wildly, as you&rsquo;ll see. The data doesn&rsquo;t, and that part matters more than the timings: a fast query that quietly returns 998 rows instead of 1,000 isn&rsquo;t fast, it&rsquo;s broken.</p>
<h2 id="one-fat-request-beats-four-lean-ones">One Fat Request Beats Four Lean Ones</h2>
<p>1,000 items in the main list, 2 warmup runs discarded, 10 timed runs per approach, interleaved so no approach got a systematically better slot. Every arm asks for the minimum it needs and no more, and every arm is chunked or paged at the ceiling I measured for that specific API rather than at a number I liked the look of. That last part cost me a rerun, and I&rsquo;ll come back to it.</p>
<table>
  <thead>
      <tr>
          <th>Approach</th>
          <th style="text-align: right">HTTP requests</th>
          <th style="text-align: right">Queries</th>
          <th style="text-align: right">Median</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CAML join, CSOM</td>
          <td style="text-align: right"><strong>1</strong></td>
          <td style="text-align: right"><strong>1</strong></td>
          <td style="text-align: right"><strong>254 ms</strong></td>
      </tr>
      <tr>
          <td>SharePoint REST <code>$batch</code></td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">355 ms</td>
      </tr>
      <tr>
          <td>CAML join, SharePoint REST *</td>
          <td style="text-align: right"><strong>1</strong></td>
          <td style="text-align: right"><strong>1</strong></td>
          <td style="text-align: right">427 ms</td>
      </tr>
      <tr>
          <td>CSOM batched, no join</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">518 ms</td>
      </tr>
      <tr>
          <td>SharePoint REST, OData expands</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">548 ms</td>
      </tr>
      <tr>
          <td>Microsoft Graph <code>$batch</code></td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">613 ms</td>
      </tr>
      <tr>
          <td>CSOM, four separate queries</td>
          <td style="text-align: right">6</td>
          <td style="text-align: right">6</td>
          <td style="text-align: right">1,192 ms</td>
      </tr>
      <tr>
          <td>Microsoft Graph</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">1,655 ms</td>
      </tr>
  </tbody>
</table>
<p>* <code>RenderListDataAsStream</code>, not <code>GetItems</code>. REST exposes CAML two ways and only one of them returns the projected columns, which is the next section and the single most useful thing I learned building this. The row also carries that endpoint&rsquo;s view chrome, a couple of dozen fields per row that nothing can trim, so it is paying for bytes the CSOM join never sends.</p>
<p>Graph needs a request per list because it can&rsquo;t traverse a lookup. It isn&rsquo;t quite empty-handed: select the lookup&rsquo;s internal name and you get its display value alongside the id, so <code>OrderDetailLookUp</code> comes back as <code>&quot;Order 00000&quot;</code> next to <code>OrderDetailLookUpLookupId: &quot;1&quot;</code>. That&rsquo;s one column from the related item, for free, and it&rsquo;s the one the lookup was configured to show. Any other column of that item, or another hop beyond it, needs its own request. My chain wants <code>customerNo</code> and <code>customerName</code> three lists away, and a lookup has exactly one <code>ShowField</code>, so Graph fetches all four lists and joins them in C#.</p>
<p>Four requests, one per list. That number used to be seven, and the three extra ones were mine, not Graph&rsquo;s: I had paged at <code>$top=999</code> out of habit, because 999 is the ceiling stuck in my head from <code>/users</code> and directory objects. It isn&rsquo;t a SharePoint number. Graph&rsquo;s default here is 200 a page and it honours <code>$top</code> literally, which I only established by seeding a 1,200-item list and counting the first page: <code>$top=999</code> gives exactly 999, <code>$top=1001</code> gives exactly 1,001.</p>
<p>Don&rsquo;t read a <code>200 OK</code> as a yes, either. <code>$top=100000</code> is accepted too, and just returns the list. Graph never complains about an over-large <code>$top</code>, so a non-error tells you nothing and the only honest test is to hold more rows than you think the ceiling is. Mine ran out at 1,200 without finding one.</p>
<p>The OData row is the interesting loser. It&rsquo;s the leanest of the lot on the wire, because <code>odata=nometadata</code> is compact and I only selected the lookup id columns. It still loses on time, because four sequential round trips cost more than one fat one. Being economical doesn&rsquo;t help when you&rsquo;re economical four times in a row.</p>
<h2 id="caml-isnt-a-csom-feature-and-i-had-that-wrong">CAML Isn&rsquo;t a CSOM Feature, and I Had That Wrong</h2>
<p>Here&rsquo;s the correction. I&rsquo;ve been writing as though CAML joins were a CSOM capability, and framing the choice as CSOM versus REST. That&rsquo;s wrong twice over.</p>
<p>CAML is SharePoint&rsquo;s query language, not a CSOM feature, and SharePoint REST will run it. There are two routes, and they don&rsquo;t behave the same:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-http" data-lang="http"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">POST /_api/web/lists(guid&#39;&lt;list-id&gt;&#39;)/GetItems
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">{ &#34;query&#34;: { &#34;ViewXml&#34;: &#34;&lt;View&gt;...&lt;/View&gt;&#34; } }
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">POST /_api/web/lists(guid&#39;&lt;list-id&gt;&#39;)/RenderListDataAsStream
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">{ &#34;parameters&#34;: { &#34;ViewXml&#34;: &#34;&lt;View&gt;...&lt;/View&gt;&#34; } }
</span></span></span></code></pre></div><p>They don&rsquo;t share a body shape, which is the first small tax. <code>GetItems</code> takes an <code>SP.CamlQuery</code> under <code>query</code>; <code>RenderListDataAsStream</code> takes a parameter bag under <code>parameters</code>. Send <code>odata=nometadata</code> and drop the <code>__metadata</code> annotation the old docs show, or you get <code>The property '__metadata' does not exist on type 'SP.CamlQuery'</code>.</p>
<p><code>RenderListDataAsStream</code> runs the join and gives you the projected columns:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-json" data-lang="json"><span style="display:flex;"><span>{ <span style="color:#f92672">&#34;Row&#34;</span>: [{
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;ID&#34;</span>: <span style="color:#e6db74">&#34;1&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;Title&#34;</span>: <span style="color:#e6db74">&#34;Main 00000&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;customerNo&#34;</span>: <span style="color:#e6db74">&#34;C-F0026&#34;</span>,
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&#34;customerName&#34;</span>: <span style="color:#e6db74">&#34;Filler Company 0026&#34;</span>
</span></span><span style="display:flex;"><span>}]}
</span></span></code></pre></div><p>That&rsquo;s the full three-hop join, over REST, one request. It&rsquo;s the <code>CAML join, SharePoint REST</code> row in the table above, and it beats every approach that doesn&rsquo;t join except one, which is the next section.</p>
<p>That snippet is trimmed, though, and the trimming matters. <code>RenderListDataAsStream</code> doesn&rsquo;t answer in the shape OData or CSOM do. The rows live under <code>Row</code> instead of <code>value</code>, every value is a string (<code>&quot;ID&quot;: &quot;1&quot;</code>, not <code>&quot;Id&quot;: 1</code>), and each row arrives with a couple of dozen fields you never asked for: <code>PermMask</code>, <code>FSObjType</code>, <code>UniqueId</code>, <code>ContentTypeId</code>, <code>SMTotalSize</code>, <code>ScopeId</code>, <code>owshiddenversion</code>, and <code>FileRef</code> in four separate encodings. <code>&lt;ViewFields&gt;</code> doesn&rsquo;t trim any of it, and neither does <code>RenderOptions: 2</code>. I&rsquo;d assumed that one was the &ldquo;just the list data&rdquo; flag; the docs define <code>ListData</code> as &ldquo;Return list data (same as <code>None</code>)&rdquo;, so it&rsquo;s the default output under a more promising name. It&rsquo;s a view-rendering endpoint, not an API, and you deserialize it accordingly.</p>
<p><code>GetItems</code> is where it gets nasty. Send the same join and you get <code>200 OK</code>, the right number of rows, and no <code>customerNo</code> or <code>customerName</code> anywhere in the response. The columns are simply gone.</p>
<p>Before you write to tell me I forgot <code>&lt;ViewFields&gt;</code>: I didn&rsquo;t, and I checked that specifically, because it&rsquo;s the obvious answer and Microsoft is explicit that a projected field has to be named there too. It was in the request. The same <code>&lt;ViewFields&gt;</code>, the same joins, the same projected fields come back fine over <code>RenderListDataAsStream</code> and fine over CSOM. Take the <code>&lt;FieldRef&gt;</code> out over CSOM and the value disappears exactly as documented, so the mechanism works and this isn&rsquo;t it. <code>GetItems</code> drops the projection with the request fully formed.</p>
<p>I assumed that meant the join had been ignored. It hasn&rsquo;t, and I made myself prove it rather than infer it from a row count. I put a <code>&lt;Where&gt;</code> on the projected <code>customerNo</code> and compared the returned item ids against the exact set my test data says should match: 10 of 1,000 at one value, 500 of 1,000 at another, and zero for a customer that doesn&rsquo;t exist. All three came back as exact set matches, not just matching counts. The clincher is that <code>customerNo</code> isn&rsquo;t a column on that list at all, so there is nothing local for the filter to resolve against; the projection is the only path.</p>
<p>So the join executes server-side, the filter across three lists is correct, and only the projected columns are lost on the way out. <code>GetItems</code> is usable for <em>finding</em> items by a value two lists away. You just can&rsquo;t read that value back, which makes it a fine filter and a useless projection.</p>
<p>Graph has neither route. Be careful how you state that, though, because &ldquo;Graph can&rsquo;t do lookups&rdquo; is too strong and I had it too strong myself until <a href="https://robwindsor.hashnode.dev/accessing-sharepoint-lookup-field-values-with-microsoft-graph">Rob Windsor&rsquo;s post</a> made me go and check. Graph reads a lookup&rsquo;s <em>value</em> perfectly well. What it cannot do is treat that lookup as a path to the rest of the related item.</p>
<p>I checked properly rather than taking anyone&rsquo;s word for it. Ask Graph to expand a lookup and it tells you exactly what&rsquo;s wrong:</p>
<pre tabindex="0"><code>Parsing OData Select and Expand failed: Could not find a property
named &#39;OrderDetailLookUp&#39; on type &#39;microsoft.graph.listItem&#39;.
</code></pre><p>The metadata says the same thing more permanently. Pull <code>https://graph.microsoft.com/v1.0/$metadata</code> and <code>listItem</code> declares six navigation properties: <code>analytics</code>, <code>documentSetVersions</code>, <code>driveItem</code>, <code>fields</code>, <code>permissions</code> and <code>versions</code>. A lookup column is not among them, and could not be. Your columns live inside <code>fields</code>, declared as <code>&lt;EntityType Name=&quot;fieldValueSet&quot; BaseType=&quot;graph.entity&quot; OpenType=&quot;true&quot; /&gt;</code>: an open type, whose properties are whatever your columns happen to be called. <code>fields</code> itself is a navigation property, which is why <code>$expand=fields</code> works at all, but nothing <em>inside</em> it is one, because a column invented at runtime can&rsquo;t be declared in a schema. There is nothing for <code>$expand</code> to follow. That&rsquo;s a design decision, not a gap in the documentation.</p>
<p>Which is why you get the display value and nothing more. The lookup&rsquo;s <code>ShowField</code> is copied into the field bag as a value, so it travels with the item. Everything else stays behind in the other list. One thing I did not test: SharePoint lets you tick extra columns when you create a lookup, under &ldquo;Add a column to show each of these additional fields&rdquo;. Those are <em>secondary</em> lookup columns on the list holding the lookup, and Graph models them as ordinary columns with <code>lookup.primaryLookupColumnId</code> pointing back at the primary, so they&rsquo;d presumably ride along the same way. That only ever spans one hop, so it wouldn&rsquo;t have rescued a three-list chain, but if your relationship is a single hop it&rsquo;s worth knowing about before you write a second request.</p>
<h2 id="batching-gets-you-the-round-trip-not-the-query-count">Batching Gets You the Round Trip, Not the Query Count</h2>
<p>This is the nuance I&rsquo;d have missed if I&rsquo;d only counted round trips, and it is where the join&rsquo;s lead is narrowest.</p>
<p>All three stacks can put several queries in one HTTP request. CSOM queues <code>GetItems</code> calls onto one context and sends them in a single <code>ExecuteQuery</code>. SharePoint REST has <code>POST /_api/$batch</code>, multipart and awkward but real. Graph has <code>POST /v1.0/$batch</code>, JSON and pleasant, capped at 20 sub-requests: the 21st comes back <code>Number of requests inside batch exceed the limit</code>.</p>
<p>And batching works. Here is the row I did not want to find:</p>
<table>
  <thead>
      <tr>
          <th></th>
          <th style="text-align: right">HTTP requests</th>
          <th style="text-align: right">Queries</th>
          <th style="text-align: right">Response bytes</th>
          <th style="text-align: right">Median</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CAML join, CSOM</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">988,195</td>
          <td style="text-align: right">254 ms</td>
      </tr>
      <tr>
          <td>SharePoint REST <code>$batch</code></td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">156,502</td>
          <td style="text-align: right">355 ms</td>
      </tr>
      <tr>
          <td>CAML join, SharePoint REST</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">1,020,047</td>
          <td style="text-align: right">427 ms</td>
      </tr>
  </tbody>
</table>
<p>The REST one is uglier than it should be, because SharePoint&rsquo;s <code>$batch</code> is multipart rather than JSON. Each part is a whole HTTP request with its own headers, and the blank lines are load-bearing:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-http" data-lang="http"><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">POST /_api/$batch
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">Content-Type: multipart/mixed; boundary=batch_a1b2c3
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">--batch_a1b2c3
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">Content-Type: application/http
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">Content-Transfer-Encoding: binary
</span></span></span><span style="display:flex;"><span><span style="color:#960050;background-color:#1e0010">
</span></span></span><span style="display:flex;"><span><span style="color:#a6e22e">GET</span> https://the-tenant.example/sites/x/_api/web/lists(guid&#39;&lt;id&gt;&#39;)/items?$select=Id,Title&amp;$top=5000 <span style="color:#66d9ef">HTTP</span><span style="color:#f92672">/</span><span style="color:#ae81ff">1.1</span>
</span></span><span style="display:flex;"><span>Accept<span style="color:#f92672">:</span> <span style="color:#ae81ff">application/json;odata=nometadata</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>--batch_a1b2c3--
</span></span></code></pre></div><p>Repeat the part per query. The response comes back as <code>multipart/mixed</code> too, one <code>HTTP/1.1 200</code> block per sub-request in the order you sent them, which you then have to pull the JSON out of yourself. Graph&rsquo;s version is a JSON array of <code>{id, method, url}</code> and is far nicer to write, but it may reorder its responses, so key them by <code>id</code> rather than by position.</p>
<p><strong>On REST, batching four plain queries beats the join.</strong> Not on round trips, which tie at one, but on time and on an order of magnitude of bytes. The join is still the fastest thing overall, but &ldquo;always join&rdquo; is the wrong lesson: it&rsquo;s &ldquo;always join <em>on CSOM</em>&rdquo;. The REST join loses because <code>RenderListDataAsStream</code> ships a megabyte of view chrome nobody asked for, and four lean OData queries in one envelope simply carry less.</p>
<p>So batching genuinely buys the round trip. What it does not buy is the query count, and that column is the one to read. The join is one query. The batched arms are three or four, riding together. Whether SharePoint charges you per request or per operation is not something my data settles, and the throttling docs say resource units are counted per operation inside a batch, so I would not assume the envelope is free.</p>
<p>Batching also can&rsquo;t filter. It drags all four lists back whole, 3,051 rows to answer a question about 1,000 of them, because you don&rsquo;t know which ids you need until the first response comes back. Which brings me to the claim I&rsquo;ve been repeating for a year, and which this exercise did not so much confirm as dismantle.</p>
<p>I&rsquo;ve been saying &ldquo;6 resource units versus 2&rdquo;, on the basis that a multi-item query costs 2 resource units. Go back to <a href="https://learn.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online">the throttling page</a> and read which sentence that table sits under: &ldquo;<strong>Microsoft Graph APIs</strong> have a predetermined resource unit cost per request.&rdquo; Much further down, past four more tables and into the &ldquo;How to handle throttling?&rdquo; section, the same page says &ldquo;CSOM and REST don&rsquo;t have a predetermined resource unit cost, and they usually consume more resource units than Microsoft Graph APIs to achieve the same functionality.&rdquo;</p>
<p>So the 2-units-per-query figure was never a <em>price</em> for the CSOM queries I was applying it to. My arithmetic borrowed Graph&rsquo;s price list for a different shop. In fairness the same page does bless the number as an estimate, &ldquo;you can estimate the request rate using an average of 2 resource units per request&rdquo;, which is a reasonable way to size a request rate and not a per-call cost you get to multiply by four and quote as a fact. The direction of the argument survives, because fewer queries is still fewer queries. The certainty doesn&rsquo;t.</p>
<p>And I should say where I said it, because it&rsquo;s still sitting there in my own writing. The 2025 joins post I linked at the top counts the units out query by query in its code comments and closes on &ldquo;66% fewer resource units&rdquo;. The CSOM performance playbook runs the same arithmetic. Both of them are wrong in the same way, this paragraph is the correction, and I&rsquo;d rather point at them than quietly hope you don&rsquo;t click through.</p>
<p>I also can&rsquo;t replace it with a measurement. The documented per-app limits are real and my measurements match them: 1,250 resource units per minute and 1,200,000 per 24 hours, which is the row for tenants up to 1,000 licences. What you can&rsquo;t easily do is watch the meter. Microsoft&rsquo;s <a href="https://devblogs.microsoft.com/microsoft365dev/prevent-throttling-in-your-application-by-using-ratelimit-headers-in-sharepoint-online/">developer blog</a> says &ldquo;when the application has consumed 80% of its resource unit quota SharePoint will start to send RateLimit headers&rdquo;, and it never says which window that 80% is measured against. I found out by pushing: 1,416 requests in 14 seconds and the headers appeared, carrying <code>RateLimit-Limit: 1250</code>. That&rsquo;s the per-minute budget, not the daily one. It&rsquo;s also a state that evaporates in about ten seconds, which makes it useless as a measuring instrument.</p>
<p>And here&rsquo;s the part that made me stop trying. The same throttling page, in a section titled RateLimit headers, currently says: &ldquo;SharePoint Online does not return or support IETF RateLimit headers.&rdquo; I have them in a response body from this afternoon. The commit history explains it better than the page does: that section was headed &ldquo;RateLimit headers - preview&rdquo; until a docs change on 7 August 2026 deleted it, with the note that there had been a preview and it was no longer there. So what I caught was a preview being switched off underneath me, eight days before I went looking. Two sections higher the page still lists &ldquo;Use the <code>Retry-After</code> and <code>RateLimit</code> HTTP headers&rdquo; as a best practice, which it hasn&rsquo;t got round to retracting.</p>
<p>Honour <code>Retry-After</code>, treat a <code>RateLimit</code> header as a bonus that has already been withdrawn once, and don&rsquo;t build a measuring instrument on either. It does mean nobody should be quoting per-call resource unit costs at you, including me.</p>
<h2 id="then-i-added-a-where">Then I Added a WHERE</h2>
<p>The part of the original post I like most is filtering on a field several lists away. So the second scenario queries the OrderTasks list and filters on the customer&rsquo;s number, two hops out:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span>CamlexNET.Interfaces.IQuery query = Camlex.Query()
</span></span><span style="display:flex;"><span>    .Where(x =&gt; (<span style="color:#66d9ef">string</span>)x[<span style="color:#e6db74">&#34;customerNo&#34;</span>] == customerNo)
</span></span><span style="display:flex;"><span>    .LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;OrderDetailLookUp&#34;</span>].ForeignList(Orders))
</span></span><span style="display:flex;"><span>    .LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;CustomerLookUp&#34;</span>].PrimaryList(Orders).ForeignList(Customers))
</span></span><span style="display:flex;"><span>    .ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;customerNo&#34;</span>].List(Customers).ShowField(<span style="color:#e6db74">&#34;customerNo&#34;</span>))
</span></span><span style="display:flex;"><span>    .ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;customerName&#34;</span>].List(Customers).ShowField(<span style="color:#e6db74">&#34;customerName&#34;</span>))
</span></span><span style="display:flex;"><span>    .ViewFields([<span style="color:#e6db74">&#34;ID&#34;</span>, <span style="color:#e6db74">&#34;Title&#34;</span>, <span style="color:#e6db74">&#34;customerNo&#34;</span>, <span style="color:#e6db74">&#34;customerName&#34;</span>]);
</span></span></code></pre></div><p>The generated <code>Where</code> targets the projected field directly, and the value type is <code>Text</code>, not <code>Lookup</code>:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-xml" data-lang="xml"><span style="display:flex;"><span><span style="color:#f92672">&lt;Where&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;Eq&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;customerNo&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Value</span> <span style="color:#a6e22e">Type=</span><span style="color:#e6db74">&#34;Text&#34;</span><span style="color:#f92672">&gt;</span>C-BROAD<span style="color:#f92672">&lt;/Value&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/Eq&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/Where&gt;</span>
</span></span></code></pre></div><p>Before running it I assumed the join would lose here. Filtering first and walking <em>backwards</em> is the obvious smart move: find the customer, find their orders, find those orders&rsquo; tasks. Three tiny, highly selective queries instead of one join across the whole list.</p>
<p>It doesn&rsquo;t win. Filtering to 500 of 1,000 rows, the join answers in one request and 168 ms; the best reverse walk needs three requests and 365 ms, and the worst needs eight and 1,658 ms. The full table is below, at the shape you&rsquo;re more likely to ship.</p>
<p>Reverse traversal doesn&rsquo;t collapse because the idea is bad. It collapses because neither REST nor Graph has an <code>in</code> operator for a set of ids, so 500 ids become a chain of <code>or</code> clauses chopped into pieces that fit inside a query string. Thirteen requests for REST, eight for Graph, which gets to send far longer chains, and I&rsquo;ll come back to why.</p>
<p>Batching rescues some of that, but less than you&rsquo;d hope, and it&rsquo;s worth being precise about why. The stages are sequential: you can&rsquo;t ask for the orders until the customers have answered. So you can only batch <em>within</em> a stage, which is why REST reverse goes from thirteen requests to two and not to one. The thirteen queries are all still there.</p>
<p>At the other end, filtering down to the 10 rows that match <code>C-NARROW</code>, reverse traversal finally gets somewhere: REST does it in 2 requests and 187 ms, batched or not. Still slower than the same filter as a CAML join over CSOM, which answers in 1 request and 108 ms. And look at what those ten rows cost on the wire: REST reverse moves <strong>1,607 bytes</strong>, the CAML join moves 10,229, and CSOM walking forward moves <strong>1,825,534</strong>. Same ten rows. That is what client-side filtering means.</p>
<h2 id="more-than-one-customer-which-is-what-you-actually-write">More Than One Customer, Which Is What You Actually Write</h2>
<p>A single <code>Eq</code> is the demo. Real code usually asks for a set: give me the tasks for these three customers. That&rsquo;s an <code>&lt;In&gt;</code> over the projected field, and it&rsquo;s fair to ask whether the operator surface on a projected column is as complete as on a real one.</p>
<p>It is. I checked <code>&lt;In&gt;</code>, <code>&lt;BeginsWith&gt;</code> and <code>&lt;Neq&gt;</code> against the ids my test data says should match, over both CSOM and REST, and all six runs came back as exact set matches:</p>
<table>
  <thead>
      <tr>
          <th>Operator on the projected <code>customerNo</code></th>
          <th style="text-align: right">Expected rows</th>
          <th>CSOM</th>
          <th>REST</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>&lt;In&gt;</code> with three customers</td>
          <td style="text-align: right">520</td>
          <td>exact</td>
          <td>exact</td>
      </tr>
      <tr>
          <td><code>&lt;BeginsWith&gt;</code></td>
          <td style="text-align: right">490</td>
          <td>exact</td>
          <td>exact</td>
      </tr>
      <tr>
          <td><code>&lt;Neq&gt;</code></td>
          <td style="text-align: right">500</td>
          <td>exact</td>
          <td>exact</td>
      </tr>
  </tbody>
</table>
<p>So here&rsquo;s the whole field, at the shape you&rsquo;d actually ship: 520 rows belonging to three customers, and what it costs to get them without a join. The <strong>Filter</strong> column is the one that repays reading. Only the join and the reverse walks filter on the server. Every <code>client</code> row fetches the entire entry list and discards what doesn&rsquo;t match with a <code>Contains</code> in C#, because <code>customerNo</code> lives two hops from the list being queried and nothing but the join can express that predicate to SharePoint. A forward arm that filtered server-side would have to resolve the customer ids first, at which point it has become a reverse arm. That isn&rsquo;t a straw man I built, it&rsquo;s the shape of the problem.</p>
<table>
  <thead>
      <tr>
          <th>Approach</th>
          <th>Filter</th>
          <th style="text-align: right">HTTP requests</th>
          <th style="text-align: right">Queries</th>
          <th style="text-align: right">Median</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>CAML join, CSOM</td>
          <td>server</td>
          <td style="text-align: right"><strong>1</strong></td>
          <td style="text-align: right"><strong>1</strong></td>
          <td style="text-align: right"><strong>169 ms</strong></td>
      </tr>
      <tr>
          <td>SharePoint REST <code>$batch</code></td>
          <td>client</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">255 ms</td>
      </tr>
      <tr>
          <td>CAML join, SharePoint REST *</td>
          <td>server</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">300 ms</td>
      </tr>
      <tr>
          <td>CSOM batched, no join</td>
          <td>client</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">351 ms</td>
      </tr>
      <tr>
          <td>SharePoint REST, OData forward</td>
          <td>client</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">367 ms</td>
      </tr>
      <tr>
          <td>SharePoint REST <code>$batch</code>, reverse</td>
          <td>server</td>
          <td style="text-align: right">2</td>
          <td style="text-align: right">13</td>
          <td style="text-align: right">377 ms</td>
      </tr>
      <tr>
          <td>CSOM per list, reverse</td>
          <td>server</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">455 ms</td>
      </tr>
      <tr>
          <td>Microsoft Graph <code>$batch</code></td>
          <td>client</td>
          <td style="text-align: right">1</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">509 ms</td>
      </tr>
      <tr>
          <td>CSOM per list, forward</td>
          <td>client</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">4</td>
          <td style="text-align: right">690 ms</td>
      </tr>
      <tr>
          <td>Microsoft Graph <code>$batch</code>, reverse</td>
          <td>server</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">9</td>
          <td style="text-align: right">732 ms</td>
      </tr>
      <tr>
          <td>Microsoft Graph, forward</td>
          <td>client</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">3</td>
          <td style="text-align: right">1,149 ms</td>
      </tr>
      <tr>
          <td>SharePoint REST, OData reverse</td>
          <td>server</td>
          <td style="text-align: right">13</td>
          <td style="text-align: right">13</td>
          <td style="text-align: right">1,163 ms</td>
      </tr>
      <tr>
          <td>Microsoft Graph, reverse</td>
          <td>server</td>
          <td style="text-align: right">9</td>
          <td style="text-align: right">9</td>
          <td style="text-align: right">1,717 ms</td>
      </tr>
  </tbody>
</table>
<p>* <code>RenderListDataAsStream</code> again.</p>
<p>The join answers in 169 ms and one request. The cheapest thing that isn&rsquo;t a join costs 1.5x that and only by giving up the filter, the honest reverse walk costs 2.2x, and the worst case is 10x and nine round trips.</p>
<p>Worth being precise about why the reverse arms blow up, because &ldquo;no <code>in</code> operator&rdquo; is only half of it. They do use <code>or</code>, and it works fine: <code>$filter=(OrderDetailLookUpId eq 2) or (OrderDetailLookUpId eq 3) or ...</code>. What kills them is that the chain has to fit in a <strong>query string</strong>, not a URL, and each stack has its own idea of how long that may be. I bisected both rather than assuming they matched:</p>
<ul>
<li><strong>SharePoint REST</strong> refuses at 2,048 characters of query string, which is ASP.NET&rsquo;s <code>maxQueryStringLength</code> default showing through. 46 clauses go through at 2,016 characters, 47 come back <code>401</code> at 2,059.</li>
<li><strong>Graph</strong> goes more than twice as far, to somewhere just past 4,625 characters. 91 clauses pass, 92 come back <code>404</code> with an empty <code>UnknownError</code> and no explanation at all.</li>
</ul>
<p>Each escaped clause costs about 43 characters either way, so REST fits about 44 ids per request and Graph about 86. An <code>in</code> operator would cost about 6 characters per id, which is why its absence hurts: same query, seven times the requests.</p>
<p>This is the rerun I owed you. I had originally chunked both stacks against a single 1,900 character budget measured on the whole URL, which is wrong twice: the cap is on the query string, and Graph&rsquo;s path carries a 90 character site id that was eating into a budget SharePoint never had to pay. Fixing it took Graph&rsquo;s reverse walk from nineteen requests to nine, which is the sort of correction that makes your own argument weaker and your numbers worth reading.</p>
<p>Three customers become 520 order tasks. REST needs twelve chunked calls to read them, on top of the one that found the orders. Thirteen round trips to answer one question. The more you ask for, the worse not joining gets.</p>
<h2 id="what-rest-and-graph-actually-refuse">What REST and Graph Actually Refuse</h2>
<p>I checked the walls rather than assuming them, and the errors are worth having:</p>
<ul>
<li><strong>Two-level <code>$expand</code> in REST</strong>: <code>400</code>. The docs never spell out a depth limit, but they do warn you off the shape, in one sentence you could read past: &ldquo;Bulk expansion and selection of related items isn&rsquo;t supported.&rdquo; In practice you name one field of one lookup and that&rsquo;s your lot.</li>
<li><strong>Reaching a lookup id <em>through</em> an expand</strong> (<code>$select=OrderTaskLookUp/OrderDetailLookUpId</code>): also <code>400</code>. If this worked, OData would do the whole chain in two calls.</li>
<li><strong><code>$filter=Id in (1,2,3)</code> in REST</strong>: <code>400</code>. No <code>in</code> operator, hence the <code>or</code> chains.</li>
<li><strong>Graph filtering on a column that lives on the lookup target</strong>: <code>400</code>. You can only filter <code>fields/CustomerLookUpLookupId</code>, the integer.</li>
<li><strong>Graph <code>in (...)</code> on a lookup id</strong>: <code>400</code>. But <code>or</code> chaining works, which is the only reason Graph&rsquo;s reverse arm is nine requests and not 500.</li>
<li><strong>Graph expanding a lookup at all</strong>: <code>400</code>, &ldquo;Could not find a property named &lsquo;OrderDetailLookUp&rsquo; on type &lsquo;microsoft.graph.listItem&rsquo;&rdquo;. Try it inside <code>fields</code> instead and the type name changes but the answer doesn&rsquo;t: <code>$expand=fields($expand=OrderDetailLookUp)</code> is <code>400</code>, &ldquo;Could not find a property named &lsquo;OrderDetailLookUp&rsquo; on type &lsquo;microsoft.graph.fieldValueSet&rsquo;&rdquo;.</li>
<li><strong>Asking for a path through a lookup</strong>, <code>$expand=fields($select=OrderDetailLookUp/Title)</code>: <code>200</code>, which looks like a win until you read it. <code>fields</code> contains exactly one thing, <code>&quot;OrderDetailLookUp&quot;: &quot;Order 00000&quot;</code>, the lookup&rsquo;s own display value. The <code>/Title</code> was quietly ignored rather than honoured or rejected.</li>
</ul>
<p>REST does have one trick I didn&rsquo;t expect: you <em>can</em> filter on an expanded lookup&rsquo;s column, even one that isn&rsquo;t the lookup&rsquo;s <code>ShowField</code>. <code>$filter=CustomerLookUp/customerNo eq 'C-NARROW'</code> with <code>$expand=CustomerLookUp</code> returns 200. That&rsquo;s what gets the OData route down to 2 requests on the narrow filter.</p>
<h2 id="gotchas">Gotchas</h2>
<ul>
<li><strong><code>GetItems</code> returns your join without the projected columns.</strong> <code>200 OK</code>, correct row count, columns missing, <code>&lt;ViewFields&gt;</code> present and correct. The filter still works, so if you only need the ids, it&rsquo;s fine. If you need the values, use <code>RenderListDataAsStream</code>.</li>
<li><strong>A projected field must also be in <code>&lt;ViewFields&gt;</code>.</strong> Leave it out and the column isn&rsquo;t on the item. No error, no warning, no empty string, just absent. CAMLEX won&rsquo;t add it for you either.</li>
<li><strong><code>ProjectedFields</code> is a whitelist, and it&rsquo;s shorter than the docs let on.</strong> I provisioned one column of each disputed type and tried to project it. Text, Number, DateTime and Currency came through. Choice, person, yes/no, hyperlink and <em>every</em> flavour of multi-line text failed, including the plain one-line <code>Note</code> that Microsoft&rsquo;s own list says is allowed. The error is <code>Value does not fall within the expected range</code>, which tells you nothing about which column it means. My workaround is to store the value in a plain text column, because I know that projects, and then put <a href="https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting">column formatting</a> on it so the user still gets the coloured pill or the icon they&rsquo;d have got from a choice column. Same experience in the list, and the column survives a join.</li>
<li><strong><code>LookupId=&quot;TRUE&quot;</code> or you&rsquo;re filtering on display text.</strong> Filter a lookup column without it and CAML compares against the shown value, not the id. You get zero rows and no error, which is the worst combination.</li>
<li><strong>The <code>In</code> clause has two limits, not one.</strong> 500 values really is a hard cap: 500 returns, 501 throws <code>Value does not fall within the expected range</code>. The other one, repeated everywhere and traced to an archived 2013 article, is 60 values, past which SharePoint is said to stop treating the column as indexed so a big list throws the list view threshold error instead. My lists are 1,000 items, so I never met that one and I would not take it on faith. At 1,000 items my no-join arm went from 4 requests to 6 purely because of that chunking.</li>
<li><strong>SharePoint REST pages at 100 by default, Graph at 200.</strong> Forget <code>$top</code> and a 1,000 item list is ten round trips before you&rsquo;ve done anything interesting.</li>
<li><strong>999 is not a SharePoint number.</strong> It&rsquo;s the directory-object ceiling from <code>/users</code>, and I paged a whole benchmark at it out of habit. Graph honours <code>$top</code> literally on list items: 999 gives 999, 1,001 gives 1,001. It also returns <code>200 OK</code> for <code>$top=100000</code> without honouring anything in particular, so a non-error tells you nothing. If you want to know your real page size, put more rows in the list than you think the cap is and count the first page.</li>
<li><strong>The query string cap is 2,048 characters on SharePoint, and mine answered <code>401</code>.</strong> Not <code>414</code>, and not the <code>400</code> that ASP.NET&rsquo;s own docs promise for this. You get &ldquo;The length of the query string for this request exceeds the configured maxQueryStringLength value&rdquo; under an Unauthorized status code, which sends you off debugging your token. Push much further past it and the status changes again, to <code>404</code>. An escaped <code>or</code> clause costs about 43 characters, so plan on roughly 45 ids per request.</li>
<li><strong>Graph&rsquo;s ceiling is its own, and roughly twice SharePoint&rsquo;s.</strong> 4,625 characters, so about 86 ids per request, and it announces the limit with a bare <code>404</code> and an empty <code>UnknownError</code>. If you chunk both stacks against one number you will silently hand Graph half the requests it needed, which is exactly what I did for the first draft of this post.</li>
<li><strong><code>RenderListDataAsStream</code> is not a drop-in swap for the OData shape.</strong> Rows under <code>Row</code>, not <code>value</code>. Every value is a string, ids included, so parse rather than cast. And you get the view&rsquo;s own fields whether you want them or not: <code>RenderOptions: 2</code> removed nothing for me, and the docs say why, since <code>ListData</code> is defined as &ldquo;same as <code>None</code>&rdquo;.</li>
<li><strong>CAMLEX still works, and <code>ToString()</code> is not the method you want.</strong> <code>Camlex.Client.dll</code> 5.4.3 built and ran fine against CSOM on .NET 10, which I mention because the last NuGet release is from July 2024 and people ask. Use <code>ToCamlQuery()</code>; <code>ToString()</code> returns fragments, and SharePoint will run them and quietly leave your projections out.</li>
</ul>
<h2 id="wrapping-up">Wrapping Up</h2>
<p>The advice survives contact with a stopwatch, but not in the shape I brought to it. Two things didn&rsquo;t survive. I&rsquo;d been selling the join as a CSOM feature and it isn&rsquo;t: CAML runs over REST too, and comes through intact on <code>RenderListDataAsStream</code>. And &ldquo;the join always wins&rdquo; is now false, because on REST a <code>$batch</code> of four ordinary queries beats the REST join on time and on bytes. What&rsquo;s left is narrower and I think truer: <strong>the CAML join over CSOM is the fastest way to do this, and the only one that keeps the filter on the server without walking the chain backwards first.</strong></p>
<p>The honest caveats: one tenant, one geography, warm caches, ten timed runs per approach, so anything inside about 20% is noise. Absolute numbers won&rsquo;t be yours. The ratios probably will be.</p>
<p>And the gap grows with the ask. One customer, one row set, and the alternatives are merely slower. Three customers and 520 rows, and the reverse walks turn into thirteen and nine round trips, not because <code>or</code> doesn&rsquo;t work but because 520 ids don&rsquo;t fit in one query string on either stack.</p>
<p>Those are the numbers after I tuned every arm to the ceiling I measured for it: <code>&lt;In&gt;</code> at its 500-value cap, SharePoint&rsquo;s or-chains at 2,048 characters, Graph&rsquo;s at 4,500 just under its measured 4,625, Graph&rsquo;s pages at a <code>$top</code> that actually returns the list. The first draft of this post had all three set to something I&rsquo;d guessed, and every one of the guesses happened to favour the join. Fixing them cost the join some of its margin and cost me an afternoon, and it&rsquo;s the only version of the table I&rsquo;d defend.</p>
<p>My rule of thumb, now with receipts behind it and one honest amendment: <strong>if your lists are connected by lookup columns, make SharePoint do the join.</strong> If you can&rsquo;t, batch. The round trips come back either way, but the join is the only thing that filters server-side without making you resolve the ids yourself first, and that&rsquo;s the part you&rsquo;d otherwise have written by hand in C# while holding an entire list in memory to do it.</p>
<p>Every number above is from lists of 1,000 items. Past 5,000 the rules change, one of these approaches starts returning partial answers with a <code>200 OK</code>, and the REST filter trick stops working entirely. I ran the whole thing again at 10,000: <a href="https://jeppe-spanggaard.dk/blogs/list-view-threshold-what-still-works/">what still works at the list view threshold</a>.</p>
]]></content:encoded></item><item><title>Efficient Multi-List Queries in CSOM: Using CAML Joins with CAMLEX</title><link>https://jeppe-spanggaard.dk/blogs/joining-multiple-lists-csom-caml/</link><pubDate>Mon, 28 Jul 2025 00:00:00 +0000</pubDate><author>Jeppe</author><guid>https://jeppe-spanggaard.dk/blogs/joining-multiple-lists-csom-caml/</guid><description>Learn how to efficiently query multiple SharePoint lists using CAML joins instead of multiple API calls to avoid throttling</description><content:encoded><![CDATA[<h2 id="the-problem-multiple-list-queries-and-throttling">The Problem: Multiple List Queries and Throttling</h2>
<p>When working with related data across multiple SharePoint lists, developers often fall into the trap of making multiple individual queries:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75715e">// ❌ Bad approach - Multiple API calls</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> customers = context.Web.Lists.GetByTitle(<span style="color:#e6db74">&#34;Customers&#34;</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> orders = context.Web.Lists.GetByTitle(<span style="color:#e6db74">&#34;Orders&#34;</span>);
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> orderItems = context.Web.Lists.GetByTitle(<span style="color:#e6db74">&#34;OrderItems&#34;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// Each query consumes 2 resource units</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> customerItems = customers.GetItems(camlQuery1);  <span style="color:#75715e">// 2 units</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> orderItems = orders.GetItems(camlQuery2);        <span style="color:#75715e">// 2 units  </span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> itemDetails = orderItems.GetItems(camlQuery3);   <span style="color:#75715e">// 2 units</span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// Total: 6 resource units + processing overhead</span>
</span></span></code></pre></div><p>This approach has several issues:</p>
<ul>
<li><strong>Higher resource consumption</strong>: Each query consumes <a href="https://learn.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online">2 resource units</a> per multi-item request</li>
<li><strong>Increased throttling risk</strong>: More API calls mean hitting limits faster</li>
<li><strong>Network overhead</strong>: Multiple round trips to SharePoint</li>
<li><strong>Complex data merging</strong>: Manual joining of results in C#</li>
</ul>
<h2 id="how-to-fix-it">How to fix it?</h2>
<p>I have worked alot with MSSQL where it is pretty easy to just join a table on a table on a table. But I did not know it was possible in CSOM. Eg. in the UI of SharePoint you can only expand one table - NOT multiple. But one day I deep dived into CAML and joins, and found out it was possible!</p>
<p><strong>Resource Unit Comparison:</strong></p>
<p>Let&rsquo;s break down the actual cost difference. According to Microsoft&rsquo;s <a href="https://learn.microsoft.com/en-us/sharepoint/dev/general-development/how-to-avoid-getting-throttled-or-blocked-in-sharepoint-online">throttling documentation</a>, each multi-item query consumes <strong>2 resource units</strong>.</p>
<p><strong>Multiple separate queries (❌ Bad approach):</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75715e">// Query 1: Get order items from main list</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> orderItems = ordersList.GetItems(query1);        <span style="color:#75715e">// 2 resource units</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// Query 2: Get customer details  </span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> customers = customersList.GetItems(query2);      <span style="color:#75715e">// 2 resource units</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// Query 3: Get order details</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> orderDetails = orderDetailsList.GetItems(query3); <span style="color:#75715e">// 2 resource units</span>
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#75715e">// Total: 6 resource units + network overhead + manual C# joining</span>
</span></span></code></pre></div><p><strong>Single join query (✅ Good approach):</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75715e">// One query with joins gets ALL the data</span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> items = ordersList.GetItems(joinQuery);          <span style="color:#75715e">// 2 resource units total</span>
</span></span></code></pre></div><p><strong>The math:</strong></p>
<ul>
<li>Multiple queries: <strong>2 units × 3 lists = 6 units</strong></li>
<li>Single join query: <strong>2 units total</strong></li>
<li><strong>Savings: 66% fewer resource units!</strong></li>
</ul>
<p>This becomes even more significant when you consider that SharePoint throttling limits are measured in resource units per time window. With joins, you can query 3x more data within the same throttling limits.</p>
<p><img src="https://jeppe-spanggaard.dk/images/CamlJoin_hu_ac4f9ad836dd7741.webp" srcset="/images/CamlJoin_hu_86b3b075eaa520a.webp 480w, /images/CamlJoin_hu_118714a818876a25.webp 720w, /images/CamlJoin_hu_ac4f9ad836dd7741.webp 1200w" sizes="(max-width: 760px) 100vw, 720px"
    width="1200" height="749"
    alt="alt text" style="background:url(data:image/webp;base64,UklGRlIAAABXRUJQVlA4IEYAAADwAwCdASoYAA8AP1mMt0upJKKYBACTFYT0gGGaEsaVl24t/frQwLnAAP7S9AkNB92WF1gIbVQK3xT5oPTvGrkAHO3MUAAA) center/cover no-repeat" loading="lazy" decoding="async"></p>
<h2 id="the-solution-caml-joins">The Solution: CAML Joins</h2>
<p>CAML actually supports joining multiple lists in a single query! This means you can get data from related lists without multiple API calls.</p>
<p><strong>First, install CAMLEX via NuGet:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-powershell" data-lang="powershell"><span style="display:flex;"><span>Install-Package Camlex.Client.dll
</span></span></code></pre></div><p><strong>Then build your join query:</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#66d9ef">var</span> list = context.Web.Lists.GetByTitle(<span style="color:#e6db74">&#34;YourMainList&#34;</span>);
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>CamlexNET.Interfaces.IQuery query = Camlex.Query();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>query = query
</span></span><span style="display:flex;"><span>.LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;OrderTaskLookUp&#34;</span>].ForeignList(ListGuidOrderTasks))
</span></span><span style="display:flex;"><span>.LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;OrderDetailLookUp&#34;</span>].PrimaryList(ListGuidOrderTasks).ForeignList(ListGuidOrders))
</span></span><span style="display:flex;"><span>.LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;CustomerLookUp&#34;</span>].PrimaryList(ListGuidOrders).ForeignList(ListGuidCustomers))
</span></span><span style="display:flex;"><span>.ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;CustomerNo&#34;</span>].List(ListGuidCustomers).ShowField(<span style="color:#e6db74">&#34;CustomerNo&#34;</span>))
</span></span><span style="display:flex;"><span>.ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;CustomerName&#34;</span>].List(ListGuidCustomers).ShowField(<span style="color:#e6db74">&#34;CustomerName&#34;</span>));
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> camlQuery = <span style="color:#66d9ef">new</span> CamlQuery();
</span></span><span style="display:flex;"><span>camlQuery.ViewXml = query.ToString();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> items = list.GetItems(camlQuery);
</span></span><span style="display:flex;"><span>context.Load(items);
</span></span><span style="display:flex;"><span>context.ExecuteQuery();
</span></span></code></pre></div><p><strong>Important:</strong> Your lists need to be connected via lookup columns for joins to work!</p>
<h2 id="why-camlex-instead-of-raw-caml">Why CAMLEX Instead of Raw CAML?</h2>
<p>I don&rsquo;t write raw CAML myself - it&rsquo;s verbose and error-prone. Instead, I use <a href="https://github.com/sadomovalex/camlex">CAMLEX</a> because:</p>
<ul>
<li><strong>Cleaner syntax</strong>: C# lambda expressions instead of XML</li>
<li><strong>IntelliSense support</strong>: Catch errors at compile time</li>
<li><strong>Easier for the next developer</strong>: Self-documenting code</li>
<li><strong>Less mistakes</strong>: No more XML typos or missing tags</li>
</ul>
<h2 id="what-else">What else?</h2>
<p>One thing is to join multiple lists, but to filter on a value 4 lists away - That is neat!</p>
<p>For example, filtering orders by the customer&rsquo;s name, which is 2 lists away:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span>CamlexNET.Interfaces.IQuery query = Camlex.Query();
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span>query = query
</span></span><span style="display:flex;"><span>.Where(x =&gt; (<span style="color:#66d9ef">string</span>)x[<span style="color:#e6db74">&#34;CustomerName&#34;</span>] == <span style="color:#e6db74">&#34;Contoso&#34;</span>) <span style="color:#75715e">// &lt;---- Filtering on join field</span>
</span></span><span style="display:flex;"><span>.LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;OrderTaskLookUp&#34;</span>].ForeignList(ListGuidOrderTasks))
</span></span><span style="display:flex;"><span>.LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;OrderDetailLookUp&#34;</span>].PrimaryList(ListGuidOrderTasks).ForeignList(ListGuidOrders))
</span></span><span style="display:flex;"><span>.LeftJoin(x =&gt; x[<span style="color:#e6db74">&#34;CustomerLookUp&#34;</span>].PrimaryList(ListGuidOrders).ForeignList(ListGuidCustomers))
</span></span><span style="display:flex;"><span>.ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;CustomerNo&#34;</span>].List(ListGuidCustomers).ShowField(<span style="color:#e6db74">&#34;CustomerNo&#34;</span>))
</span></span><span style="display:flex;"><span>.ProjectedField(x =&gt; x[<span style="color:#e6db74">&#34;CustomerName&#34;</span>].List(ListGuidCustomers).ShowField(<span style="color:#e6db74">&#34;CustomerName&#34;</span>));
</span></span><span style="display:flex;"><span>
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> camlQuery = <span style="color:#66d9ef">new</span> CamlQuery();
</span></span><span style="display:flex;"><span>camlQuery.ViewXml = query.ToString();
</span></span><span style="display:flex;"><span><span style="color:#66d9ef">var</span> items = ordersList.GetItems(camlQuery);
</span></span></code></pre></div><p>This CAMLEX query automatically generates the following CAML XML - notice how complex the raw XML is compared to the clean C# syntax above:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-xml" data-lang="xml"><span style="display:flex;"><span><span style="color:#f92672">&lt;View&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;Query&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Where&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;Geq&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;customerName&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;Value</span> <span style="color:#a6e22e">Type=</span><span style="color:#e6db74">&#34;Text&#34;</span><span style="color:#f92672">&gt;</span>Contoso<span style="color:#f92672">&lt;/Value&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;/Geq&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/Where&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/Query&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;ViewFields&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;Id&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;customerNo&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;customerName&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/ViewFields&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;Joins&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Join</span> <span style="color:#a6e22e">Type=</span><span style="color:#e6db74">&#34;LEFT&#34;</span> <span style="color:#a6e22e">ListAlias=</span><span style="color:#e6db74">&#34;0f0cfc71-1c6e-4fd4-b6f2-279d0e3862f4&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;Eq&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;OrderTaskLookUp&#34;</span> <span style="color:#a6e22e">RefType=</span><span style="color:#e6db74">&#34;Id&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">List=</span><span style="color:#e6db74">&#34;0f0cfc71-1c6e-4fd4-b6f2-279d0e3862f4&#34;</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;Id&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;/Eq&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/Join&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Join</span> <span style="color:#a6e22e">Type=</span><span style="color:#e6db74">&#34;LEFT&#34;</span> <span style="color:#a6e22e">ListAlias=</span><span style="color:#e6db74">&#34;ce57b9a2-5052-482c-a8c8-150c7d59ced3&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;Eq&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">List=</span><span style="color:#e6db74">&#34;0f0cfc71-1c6e-4fd4-b6f2-279d0e3862f4&#34;</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;OrderDetailLookUp&#34;</span> <span style="color:#a6e22e">RefType=</span><span style="color:#e6db74">&#34;Id&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">List=</span><span style="color:#e6db74">&#34;ce57b9a2-5052-482c-a8c8-150c7d59ced3&#34;</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;Id&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;/Eq&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/Join&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Join</span> <span style="color:#a6e22e">Type=</span><span style="color:#e6db74">&#34;LEFT&#34;</span> <span style="color:#a6e22e">ListAlias=</span><span style="color:#e6db74">&#34;e204ed0f-7c25-432f-9228-3eb438c527e2&#34;</span><span style="color:#f92672">&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;Eq&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">List=</span><span style="color:#e6db74">&#34;ce57b9a2-5052-482c-a8c8-150c7d59ced3&#34;</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;CustomerLookUp&#34;</span> <span style="color:#a6e22e">RefType=</span><span style="color:#e6db74">&#34;Id&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>        <span style="color:#f92672">&lt;FieldRef</span> <span style="color:#a6e22e">List=</span><span style="color:#e6db74">&#34;e204ed0f-7c25-432f-9228-3eb438c527e2&#34;</span> <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;Id&#34;</span> <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>      <span style="color:#f92672">&lt;/Eq&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;/Join&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/Joins&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;ProjectedFields&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Field</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;customerNo&#34;</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">Type=</span><span style="color:#e6db74">&#34;Lookup&#34;</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">List=</span><span style="color:#e6db74">&#34;e204ed0f-7c25-432f-9228-3eb438c527e2&#34;</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">ShowField=</span><span style="color:#e6db74">&#34;customerNo&#34;</span> 
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">&lt;Field</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">Name=</span><span style="color:#e6db74">&#34;customerName&#34;</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">Type=</span><span style="color:#e6db74">&#34;Lookup&#34;</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">List=</span><span style="color:#e6db74">&#34;e204ed0f-7c25-432f-9228-3eb438c527e2&#34;</span> 
</span></span><span style="display:flex;"><span>      <span style="color:#a6e22e">ShowField=</span><span style="color:#e6db74">&#34;customerName&#34;</span>
</span></span><span style="display:flex;"><span>    <span style="color:#f92672">/&gt;</span>
</span></span><span style="display:flex;"><span>  <span style="color:#f92672">&lt;/ProjectedFields&gt;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">&lt;/View&gt;</span>
</span></span></code></pre></div><p>Imagine having to write and maintain that XML manually! This is exactly why CAMLEX is so valuable - you get all the power of CAML joins with readable C# syntax.</p>
<h2 id="performance-benefits">Performance Benefits</h2>
<p><strong>Before (Multiple queries):</strong></p>
<ul>
<li>🔴 6+ resource units</li>
<li>🔴 Multiple network calls</li>
<li>🔴 Complex C# merging logic</li>
</ul>
<p><strong>After (Single join):</strong></p>
<ul>
<li>✅ 2 resource units only</li>
<li>✅ One network call</li>
<li>✅ Server-side joining</li>
</ul>
<h2 id="key-takeaways">Key Takeaways</h2>
<ul>
<li><strong>Use joins instead of multiple queries</strong> to reduce resource consumption</li>
<li><strong>CAMLEX makes CAML readable</strong> for you and the next developer</li>
<li><strong>You can filter on joined data</strong> even multiple lists away</li>
<li><strong>SharePoint UI limitations ≠ API limitations</strong> - joins work even if the UI doesn&rsquo;t show it</li>
</ul>
<h2 id="common-issues--solutions">Common Issues &amp; Solutions</h2>
<p><strong>❌ &ldquo;List does not exist&rdquo; error</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75715e">// Use list GUIDs instead of names for reliability</span>
</span></span><span style="display:flex;"><span>.ForeignList(<span style="color:#66d9ef">new</span> Guid(<span style="color:#e6db74">&#34;12345678-1234-1234-1234-123456789012&#34;</span>))
</span></span></code></pre></div><p><strong>❌ &ldquo;Field not found&rdquo; error</strong></p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-csharp" data-lang="csharp"><span style="display:flex;"><span><span style="color:#75715e">// Use internal field names, not display names</span>
</span></span><span style="display:flex;"><span>.ShowField(<span style="color:#e6db74">&#34;Title&#34;</span>)        <span style="color:#75715e">// ✅ Internal name</span>
</span></span><span style="display:flex;"><span>.ShowField(<span style="color:#e6db74">&#34;Customer Name&#34;</span>) <span style="color:#75715e">// ❌ Display name</span>
</span></span></code></pre></div><p><strong>❌ Join returns no data</strong></p>
<ul>
<li>Verify lookup columns exist and are properly configured</li>
<li>Check that you&rsquo;re joining on the correct fields</li>
<li>Ensure the lookup field contains valid IDs</li>
</ul>
<p><strong>❌ &ldquo;Cannot project this field type&rdquo; error</strong></p>
<p>Only specific field types can be included in ProjectedFields:</p>
<p>✅ Supported ProjectedFields types:</p>
<ul>
<li>Calculated (treated as plain text)</li>
<li>ContentTypeId</li>
<li>Counter</li>
<li>Currency</li>
<li>DateTime</li>
<li>Guid</li>
<li>Integer</li>
<li>Note (one-line only)</li>
<li>Number</li>
<li>Text</li>
</ul>
<p>❌ NOT supported in ProjectedFields:</p>
<ul>
<li>Multi-line text fields</li>
<li>Rich text fields</li>
<li>Choice fields</li>
<li>Lookup fields (use joins instead)</li>
<li>User/Person fields</li>
<li>Managed metadata fields</li>
</ul>
<p><strong>💡 Pro tip:</strong> If you need data from unsupported field types, query them separately after getting your joined results.</p>
<p>CAML joins are one of five techniques in <a href="https://jeppe-spanggaard.dk/blogs/sharepoint-csom-performance-playbook/">The SharePoint CSOM Performance Playbook</a>, which covers when a join is the right answer and when batching or change detection would serve you better.</p>
]]></content:encoded></item></channel></rss>