var repo = new GenericRepository(context); var myObject = new MyObject { Property1 = "value1", Property2 = "value2" }; repo.AddOrUpdate(myObject);
var repo = new GenericRepository(context); var myObject = repo.GetById(1); myObject.Property1 = "new value"; repo.AddOrUpdate(myObject);
var repo = new GenericRepositoryThe package library for IGenericRepository AddOrUpdate method is likely a custom implementation or a third-party library that provides a generic repository implementation for C# applications. Some popular examples include Entity Framework, Dapper, and NHibernate.(context); var myObjects = repo.GetAll().Where(o => o.Property1 == "old value"); foreach(var myObject in myObjects) { myObject.Property1 = "new value"; repo.AddOrUpdate(myObject); }