2013年9月3日 星期二

[轉貼] LINQ傻瓜教學之三:更改列名如何寫select isnull(column1,0) as StoreName from table1

出處:http://blog.csdn.net/avi9111/article/details/4752692

其實很簡單,就是
Area = store.stm_lArea.GetValueOrDefault(0)
Data.dcDataContext dc = new Data.dcDataContext(this.gzConnectionString);
var stores = from store in dc.StoreMaster_stm
select new
{
Name = store.stm_cStoreName,
Area = store.stm_lArea.GetValueOrDefault(0),
OpenDate = store.stm_dOpenDate.GetValueOrDefault(DateTime.Parse("2009-10-1")),
Desc = store.stm_cDesc.ToString()
};

GridView1.DataSource = stores;
GridView1.DataBind();

沒有留言:

張貼留言