This project is an extension of Alexinea.FastMember. Read and write property based on FastMember.
In addition, we also recommend that you use Leo based on NCC Natasha, a high-performance object reading and writing component.
Install-Package Alexinea.FastMember.Extensions
Get the value from the object.
var model = new Model();
var val1 = model.GetPropertyValue(typeof(Model), "PropertyName"); // model may be an object
var val2 = model.GetPropertyValue("PropertyName"); // model must be a specific type
var val3 = model.GetPropertyValue(t => t.PropertyName);
To set a value into the object.
var model = new Model();
model.SetPropertyValue(typeof(Model), "PropertyName", value); // model may be an object
model.SetPropertyValue("PropertyName", value); // model must be a specific type
model.SetPropertyValue(t => t.PropertyName, value);