c# - Insert again elements from one list to the prior list -


here situation. have 2 list of same type. imagine names these. fulllist , elementsremoved. in order avoid database roundtrip, anytime delete element fulllist added list of elementsremoved in case of regret's user can revert deletion.

i thinking loop inside elementsremoved insert them again fulllist removed.

there way simple list methods.

something

fulllist.insert, add, ..... (x =>  

in order reduce line code , optimized?

in front end make class holds bool , object:

public class delpair<t>{    public bool isdeleted{get;set;}    public t item{get;set;} } 

now instead of using list of objects use list of delpair<yourclass> , set isdeleted=true when deleting.

this pattern allow track other things, such ismodified if comes that.

based on op comment he's using entity class , needs function such:

one option make delpair class inherit entity. may put implicit casting operator:

...    // not sure signature, trial/error should :)    public static implicit operator t(delpair<t> pair)     {       return pair.item;    } 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -