Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

LINQ to SharePoint - Single() vs Where().Single()

$
0
0

First query generates CAML without ID condition. Does it mean, that all items are read and query is executed in memory?

var result = db.Agreements.Single(i => i.Id == 8);

<Query><Where><BeginsWith><FieldRef Name="ContentTypeId" /><Value Type="ContentTypeId">0x010</Value></BeginsWith></Where></Query>

Second query generates CAML with ID condition:

var result = db.Agreements.Where(i => i.Id == 8).Single();

<Query><Where><And><BeginsWith><FieldRef Name="ContentTypeId" /><Value Type="ContentTypeId">0x010</Value></BeginsWith><Eq><FieldRef Name="ID" /><Value Type="Counter">8</Value></Eq></And></Where></Query>

Single is not mentioned as unsuported command. Does anybody have explanation for this behavior of LINQ to SP?
https://msdn.microsoft.com/en-us/library/ee536585.aspx#sectionSection0


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>