So, i have this object for exemple:
public class User
{
public int Id { get; set; }
public string Name { get; set; }
public List<Car> Cars { get; set; }
public List<User> Children { get; set; }
}
public class Car
{
public int Id { get; set; }
public string Name { get; set; }
public string Color { get; set; }
}
So, there is a way to update a User object, updating it Children and Cars?
If there isn’t a car in the object to update that there is in the new object, add it, but if there is in the object to update and there isn’t in the new object, remove it from the object to update, and update all attributes for all cars that are matched, and also to the Childrenproperty.
Is it possible?
Yes! It’s possible, here the solution (this solution update all properties, class properties and collection properties, but if there is an class inside, the class needs to inherit of an AbstractEntity):
An exemple of the usage:
The AbstractEntity:
The exemple classes:
Using the method: