charan sri

charan sri

  • NA
  • 10
  • 21.4k

linq query for update more than one record

Oct 11 2012 5:46 AM

I have a table named industries. In this my fields are

workfor_id,workfor_usr_id,workfor_industry_id

With the same values of workfor_id, I have different workfor_industry_id's.

foreach (var k in us){ 
   
var ind = dbContext.industries.Where(i => i.workfor_id ==
        k
.id).Select(i => i).FirstOrDefault();
   
string ind2 = k.industry;
   
var industryParts =   ind2.Split(',');
   
var o = (industryParts.Length);
   
for (c = 0; c < o; c++){
    ind
.workfor_id = Convert.ToInt16(k.id);
    ind
.workfor_industry_id = Convert.ToInt16(k.industryid); }
     
}

To update workfor_industry_id field I have implemented inner loop inside the foreach loop to get the values of workfor_industry_id's.here same record is over loading with different workfor_industry_id's.

can you tell me how to implement this.



Answers (1)