Dhanilan
Dhanilan
@tegeek we need to pass updateDefinition as a parameter UpdateEntityAsync(T entity, UpdateDefinition updateDefinition); . Is that fine?
Okay thanks @RobThree . I will use ReplaceOneAsync for Update. (Update entire document).
Committed the same . Please review them . Have added the test case also. Thanks
@tegeek won't that be complicated to build UpdateDefinition for the generic class T? May be loop through the properties of the class?please advice.
Something like this? ``` UpdateDefinition updateDefinition= Builders.Update.Set(x=>x.Id, entity.Id); var props = typeof(T).GetType().GetProperties(); foreach (var propertyInfo in props) { if (propertyInfo.CanRead) updateDefinition.Set(propertyInfo.Name ,propertyInfo.GetValue(entity,null)); } this.collection.UpdateMany(GetIDFilter(entity.Id), updateDefinition); ```
Yea. I never wanted to do that way. Meanwhile shall update you if I found better approach. Thanks