c# - mvc3 getting a DB model remove error -


i doing database check see if rows expired getting system.data.entity.dbset error on db.servicers.remove(servicer) saying piece of code has invalid arguments .my little code is

var servicer = (from s in db.servicers                 datetime.now >= s.expired select s).tolist();          if (servicer.any())         {             db.servicers.remove(servicer);             db.savechanges();         } 

the expired field datetime , want loop database , delete record expires today or has expired; whats best way solve error.

like lews therin said remove takes type t should enumerate list.

var servicer = (from s in db.servicers                 datetime.now >= s.expired select s).tolist();      if (servicer.any())     {         foreach(var s in servicer)          {             db.servicers.remove(s);         }         db.savechanges();     } 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -