I want to get a SPListItem
from a SPList
where a field match a value. I have to ways to do it, CAML
and LINQ
.
My code is:
LINQ
...
SPList list = Web.Lists["MyList"];
SPListItem item = (from SPListItem it in list.Items
where it["A_Field"] == "A_Value"
select it).First();
....
CAML
...
SPList list = Web.Lists["MyList"];
SPQuery query = new SPQuery();
query.Query = @"
<Where><Eq>
<FieldRef Name=""A_Field""/><Value Type=""Text"">A_Value</Value>
</Eq></Where>";
SPListItem item = list.GetItems(query).Cast<SPListItem>().First();
....
I have read in some blogs (like this) that there is a performance issue with LINQ
.
What is the better way to do it from scope of performance?