I have the scenario where I have a List of selected attributes in string format. Based on that list I want to perform an operation on actual object collection to check whether given properties having unique value combination within that list.
Example - Here Name and Type are the selected attributes (given in selectedProductAttributes list) we want to check uniqueness for this attributes with products collection. We might use reflection to retrieve actual properties but I am not sure how to achieve this. Any help appreciated.
public class Product
{
public string Name { get; set; }
public string Type { get; set; }
public string Price { get; set; }
}
private List<string> selectedProductAttributes = new List<string> {"Name", "Type"};
private List<Product> products = new List<Product>
{
new Product {Name= "a", Type="t1", Price=10},
new Product {Name= "a", Type="t1", Price=20},
new Product {Name= "b", Type="t2", Price=30}
};
Aucun commentaire:
Enregistrer un commentaire