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
Post a Comment