c# - linq magic, delete all rec where -


user has list of userclaims.

i sending user claimtype , claimvalue parameters. based on params want delete user claims if any.

user has list of claims , every claim has it's user , type , value.

public void removeclaim(user user, string type, string value) {     var claimsrepository = repository.findall().tolist(); } 

once again want delete users claims has type , value sent params in method.

this work if "repository" list, ienumerable isn't enough, doesn't have add/remove functions.

if meet criteria, removeall:

repositiory.removeall(c => c.type == type && c.value == value); 

otherwise, use where remove (again, needs support remove function):

foreach (userclaim c in repositiory.where(c => c.type == type && c.value == value).tolist())     repository.remove(c); 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -