求高手解答,解决方案
求高手解答,急~~~~
我想查DHLFreights 的某一个字段 countryDHLId 可能是Area1~~~Area9,可是为什么不能把这个字段的数据查出来呢
------解决方案--------------------
string countryDHLId = "Area" + countryInfo.DHLArea.ToString();
var info = from df in db.DHLFreights
where df.WeightMax >= weight && df.WeightMin <= weight
select new
{
countryDHLId
};
double dhlFreight = double.Parse(info.First().countryDHLId);
我想查DHLFreights 的某一个字段 countryDHLId 可能是Area1~~~Area9,可是为什么不能把这个字段的数据查出来呢
------解决方案--------------------
string countryDHLId = "Area" + countryInfo.DHLArea.ToString();
var info = from df in db.DHLFreights
where df.WeightMax >= weight && df.WeightMin <= weight
select GetPropertyValue(df,countryDHLId);
private static object GetPropertyValue(object obj, string property)
{
System.Reflection.PropertyInfo propertyInfo=obj.GetType().GetProperty(property);
return propertyInfo.GetValue(obj, null);
}