Bulk updates using linq entities -


i have list of object list category has properties, categoryid, categoryname, categorymessage,

i have use list update records in database table categories, has same columns categoryid, categoryname, categorymessage items in list have matching categoryid in database table

how can bulk update, using entity framework extensions, examples saw have update value hard coded below, (statusid =2), whereas me value has retrieved item in list matches categoryid in database table.

 context.tasks.update( t => t.statusid == 1,  t => new task {statusid = 2}); 

thanks in advance.

i not sure whether looking for? haven't run code.

 list<category> categorylist = new list<category> {                         new category { id = 1, message = "a", name = "a"},                         new category { id = 2, message = "b", name = "b"},                         new category { id = 3, message = "c", name = "c"},                         new category { id = 4, message = "d", name = "d"},                 };         using (var container = new model1container())         {            iqueryable<category> categoryqueryable = container.categories.where(x => categorylist.any(t => t.id == x.id));            foreach (category item in categoryqueryable)            {                var categorysource = categorylist.where(x => x.id == item.id).select(m => m).firstordefault();                item.message = categorysource.message;                item.name = categorysource.message;            }                  container.savechanges();         } 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -