DevJohnC/DataKit

[Mapping] API for easy assigning single fields

DevJohnC opened this issue · 0 comments

An API for assigning a single field's value via IDataModelWriter would make code that needs to perform simple mapping tasks without a full, constructed, compiled mapping method, much easier to author and maintain.

Current:

var fieldGraphPath = TypeModel.GetModelOf<TView>()
    .GetField(obj => obj.PropertyToAssign);
var modelReadWriter = new ObjectDataModelWriter<TView>(viewInstance);
modelReadWriter.WriteField<Guid>(fieldGraphPath.Field, Guid.NewGuid());

The current has a problem of not navigating to the correct position in the object graph, with error handling, and returning back to the current position in the graph. It's also possibly overly verbose.