I have a class:
public class LotInfo
{
public string lotn { get; set; }
public string imlitm { get; set; }
public string imdsc { get; set; }
public string wplotn { get; set; }
public int wptrdj { get; set; }
public DateTime wptrdj_d { get; set; }
public string wplitm { get; set; }
public int wptrqt { get; set; }
public string wpkyfn { get; set; }
public int wpdoco { get; set; }
public string iolitm { get; set; }
public string iodcto { get; set; }
public int iodoco { get; set; }
public int ioub04 { get; set; }
}
I have 2 instances.
Object1 and Object2
I want to inject object2 -> object1 for specific properties.
So i have overridden the Match method like this:
public class LotInfoInject : ConventionInjection
{
protected override bool Match(ConventionInfo c)
{
return c.SourceProp.Name.StartsWith("io");
}
}
and i am using the injecter like this:
object1.InjectFrom(object2);
I cant figure out why i am getting the exception.
{"Object of type 'System.String' cannot be converted to type 'System.Int32'."}
If i DONT override the Match method it works but i am getting properties that i dont want replaced from object1
any ideas?
You're trying to put iolitm (string) in iodoco (int).
Try like this:
public class LotInfoInject : ConventionInjection
{
protected override bool Match(ConventionInfo c)
{
return c.SourceProp.Name.StartsWith("io")
&& c.SourceProp.Name == c.TargetProp.Name;
}
}