I have a configuration defined for duplicate check on each property in my model below
public class ConfigurationModel
{
public GroupValue Value1 { get; set; }
public GroupValue Value2 { get; set; }
public GroupValue Value3 { get; set; }
public GroupValue Value4 { get; set; }
public GroupValue Value5 { get; set; }
}
public class GroupValue
{
public bool duplicateCheck { get; set; }
}
I have the real class which has all the properties defined like Value1, Value2 etc, which we will call it as OrderModel
public class OrderModel
{
public string Value1 { get; set; }
public string Value2 { get; set; }
public string Value3 { get; set; }
public string Value4 { get; set; }
public string Value5 { get; set; }
}
Now I want to include only those properties for duplicate check which have the respective flag in configuration set to true. Example
bool CheckDuplicate(OrderModel newOrder)
{
OrderModel existingOrder = //GetfromDB;
//Compare only those properties in newOrder and existingOrder which have duplicate check set to true in ConfigurationModel
}
Using reflection to getproperties by string name and then compare is what I had in mind, But wanted to check the best way to do it, keeping performance in mind as well. Any help would be greatly appreciated.
Thanks, AK
Aucun commentaire:
Enregistrer un commentaire