您好我有这个代码,我从存储过程中检索数据。目前它适用于两种方法,因为从存储过程返回的列是相同的但现在问题是我必须添加第三种方法说方法GetDataC(数据完全相同...但是有人写了proc返回不同的列名称)例如对于AA我有_AA for BB我有BBsometext。我不想复制GetSomeData方法。
public IList<SomeData> GetDataA(Query q)
{
var ds = someService.GetA(q);
return GetSomeData(ds);
}
public IList<SomeData> GetDataB(Query q)
{
var ds = someService.GetB(q);
return GetSomeData(ds);
}
private IList<SomeData> GetSomeData(DataSet ds)
{
IList<SomeData> SomeData = new List<SomeData>();
var helper = new DataSetHelper(ds);
if (helper.HasRows())
{
foreach (DataRow row in helper.GetRows())
{
SomeData.Add(new SomeData
{
AA = helper.GetNullableDouble(row, "AA"),
BB = helper.GetNullableDouble(row, "BB"),
CC = helper.GetNullableDouble(row, "CC"),
EE = helper.GetNullableInt(row, "DD"),
FF = helper.GetNullableDouble(row, "EE"),
GG = helper.GetNullableDouble(row, "FF"),
});
}
}
return someData;
}
}
有办法做到这一点吗?