我正在尝试创建如下列表并使用数据读取器中的值对其进行更新。我在编写代码以从数据阅读器更新此列表时需要帮助。
internal IList<FilingDto> LoadStatusDtofromReader(IDataReader reader)
{
IList<FilingDto> filingstatus = new List<FilingDto>();
while (reader !=null && reader.Read())
{
var dto = new FilingDto();
var Year = (Decimal)reader["Year"];
dto = new FilingDto()
{
Controllerid = (Guid)reader["Collectorid"],
Status = DBNull.Value.Equals(reader["Status"]) ? string.Empty : reader["Status"].ToString(),
Year = Convert.ToInt32(Year),
Level = DBNull.Value.Equals(reader["Level"]) ? string.Empty : reader["ServiceLevel"].ToString()
};
filingstatus.Add(dto);
}
return status;
}
从数据读取器读取的代码如下,但我被困在两者之间,请帮我完成这个
DataTable FilingStatus = new DataTable("FilingStatus");
SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["Connectionstring"].ConnectionString);
sqlcon.Open();
SqlCommand cmd = new SqlCommand("select Collectorid, Status, Year, Level from dbo.abc", sqlcon);
using (IDataReader dr =