Reputation: 36733
Assuming I already have type of shipping I need to find in variables:
var categoryLand = ciudad.CategoriaTierra; //string: "A"
var categoryAir = ciudad.CategoriaAvion; //string "G"
And that I also have the specific instance of the ShippingProducto
object I want to use:
EFShippingProductoRepository productRepository = new EFShippingProductoRepository();
int convProductId = Convert.ToInt32(productId);
var product = productRepository.FindProductById(convProductId);
How can I find the value inside the column named categoryLand
? For example, if in the code above, categoryLand
had the value "C", I need to find the value inside of the column C
.
Any suggestions?
Upvotes: 0
Views: 83
Reputation: 1377
You can get the property value via reflection:
object value = product.GetType().GetProperty(categoryLand).GetValue(product,
null);
Upvotes: 1