SqlDataReader返回值 [英] SqlDataReader Returned Values

查看:137
本文介绍了SqlDataReader返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个定义以下项目的课程。 




 public int Tid {get;组; } 
public string TDesc {get;组; }
public string TNotes {get;组; }
public DateTime TDate {get;组; }
public int TPercent {get;组; }



while(reader.Read())
{
var tasklist = new Task();
//tasklist.Tid = reader.GetInt32(0);
tasklist.TDesc = reader.GetString(1);
tasklist.TNotes = reader.GetString(2);
tasklist.TDate = reader.GetDateTime(3);
tasklist.TPercent = reader.GetInt32(4);
taskdata.Add(tasklist);
}

每当运行sqldatareader并撤回要读取的数据并添加到'var tasklist'时,是否有办法采取  tasklist.TDesc并将其添加为
tasklist.Description,以便数据的标题指示Description而不是TDesc。



我知道这个措辞有点奇怪。

解决方案

你好,


你可以只允许一个设置为TDESC并创建一个只有一个返回TDESC值的get的新属性。 / p>


I have a class that defines the following items. 


public int Tid { get; set; }
public string TDesc { get; set; }
public string TNotes { get; set; }
public DateTime TDate { get; set; }
public int TPercent { get; set; }



while (reader.Read())
  {
       var tasklist = new Task();
//tasklist.Tid = reader.GetInt32(0);
tasklist.TDesc  = reader.GetString(1);
tasklist.TNotes = reader.GetString(2);
tasklist.TDate = reader.GetDateTime(3);
tasklist.TPercent = reader.GetInt32(4);
taskdata.Add(tasklist);
}

Whenever the sqldatareader is ran and pulls back the data to be read and added to the 'var tasklist', is there a way to take tasklist.TDesc and have it be added as tasklist.Description so that the header of the data indicates Description instead of TDesc.

I know this I a little strangely worded.

解决方案

Hello,

you could allow only a set to TDESC and make a new property with only a get that returns the value of TDESC.


这篇关于SqlDataReader返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆