NIRANJAN G NIRANJAN G - 2 months ago 4x
C# Question

linq query to update multiple rows

I am trying to update multiple rows using linq. My table structure is as below.

id uploadID Label Value
1 100 docNumber 123
2 100 expiryDate 1/1/2017

My DAL function is as below.

public int updatedocDetails(int upld_id, string docnumber, string expiryDate, string username)


In function i am recieving uploadId(for ex 100) and (docNumber for ex 456 and expiryDate for ex 2/2/2017)

So my resulting table should be

id uploadID Label Value
1 100 docNumber 456
2 100 expiryDate 2/2/2017

Is there anyway I can achieve this by using Linq? thank you in advance

woz woz

Something like this should work:

List<Record> records = (from p in Context.Records
                        where .... // add where condition here
                        select p).ToList();

records[0].Value = 456;
records[1].Value = '2/2/2017';