GenericRepository TEntity change attribute value
问题 I am using EF 5.0 and the model first approach. I have build a GenericRepository that has the basic get, insert, delete etc statements. Like: public virtual void Insert(TEntity entity) { dbSet.Add(entity); } My EF entities all have the attributes Modified and ModifiedBy. Now I want to change this values everytime I save an entity. Is it possible to modify this two attributes (set the value) without writing an specific implementation all the time? Thank you 回答1: I see two options for you to do