Finally I got the point that why we need "LINQ".
With the help of "LINQ", we can process a list of data in C#, just like what we do in SQL statements. The data in C# is no longer like a list of "single value", but a "stream". Instead of process one hundred variable (which normally stored in a List or an Array variable) one by one, we can process all the data in one go.
I know it's a bit late to understand such a simple concept. Well, better late than never.
:-)
Showing posts with label LINQ. Show all posts
Showing posts with label LINQ. Show all posts
Wednesday, January 15, 2014
Monday, September 6, 2010
How to update lookup column through LINQ in SharePoint 2010
To update lookup field through LINQ, there is a tricky issue: we need to update "Display" column instead of "ID".
Below is the sample code. The column "Animal" is a lookup column.
using (ServerDataContext ctx = new ServerDataContext(strSiteUrl))
{
EntityList<TestList1Item> Customers = ctx.GetList<TestList1Item>("testList1");
var query = from c in Customers.ToList()
select c;
foreach (var cust in query)
{
//cust.Animal.Id = 2;
cust.Animal.Title = "Dog";
}
ctx.SubmitChanges();
}
Subscribe to:
Comments (Atom)