I Would like to know why is this method found as an answer on many questions here not working, there are errors in "KnownSourceValueInjection". Also "GetByName(...)"is not working, it says: "propertyinfo[]" does not contain a definition for "GetByName" accepting a first argument of type "propertyinfo[]" could be found.I'm working on a web service. I'm using:
- using Omu.ValueInjecter;
- using Omu.ValueInjecter.Utils;
- using Omu.ValueInjecter.Injections;
This is the method.
public class ReaderInjection : KnownSourceValueInjection<IDataReader>
{
protected override void Inject(IDataReader source, object target)
{
for (var i = 0; i < source.FieldCount; i++)
{
var activeTarget = target.GetProps().GetByName(source.GetName(i), true);
if (activeTarget == null) continue;
var value = source.GetValue(i);
if (value == DBNull.Value) continue;
activeTarget.SetValue(target, value);
}
}
}