最近因为一直在看ext
所以和json 打交道打的比较多,
以前都是习惯性的
把数据读到dataset
之后调用ConvertToJson方法
(博客园有这个,只不过与ext的json稍微有点bug,更正在下面)

从数据库中读数据中寻找若隐若现的OOPusing System;
从数据库中读数据中寻找若隐若现的OOP
using System.Data;
从数据库中读数据中寻找若隐若现的OOP
using System.Configuration;
从数据库中读数据中寻找若隐若现的OOP
using System.Web;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.Security;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI.WebControls;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI.WebControls.WebParts;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI.HtmlControls;
从数据库中读数据中寻找若隐若现的OOP
using System.Text;
从数据库中读数据中寻找若隐若现的OOP
using System.Collections;
从数据库中读数据中寻找若隐若现的OOP
using System.Globalization;
从数据库中读数据中寻找若隐若现的OOP
using System.Reflection;
从数据库中读数据中寻找若隐若现的OOP


随着项目的深入,
我发现这么做好处很显然,速度快,但是坏处也有,东西一多,到处都是dataset。。。
看了<你必须知道的.net >后,
我就在想,是不是我们需要把这些封装到类里面来传呢?

比如说表 
----------------------------------
table customers
----------------------------------
id                           int (PK)
name                      nvarchar(10)
sex                        bit
phone                    nvarchar(15)
Email                     nvarchar(30)
.                           .
.                           .
.                           .
----------------------------------
中,我先定义个类,基本情况如下


—————————————————
Student
—————————————————
+Id :int
+Name:string
+Sex:bool
+Phone:string
+Email:string
—————————————————
changeName(string):void
.
.
.
—————————————————
之后实例化它,先将表中的信息填写到这个对象里面
之后通过Json.Net 中的
string json = JavaScriptConvert.SerializeObject(student);
这样的话貌似每个都变成了对象方便处理,当然,也复杂不少。。。。

初学者,以往的blog 都不敢公开,
写到这个确实觉得确实有点意思,决定第一次放到新手区。。
希望得到各位高手指教,本人先在这里谢谢大家了。

code在下
从数据库中读数据中寻找若隐若现的OOPusing System;
从数据库中读数据中寻找若隐若现的OOP
using System.Data;
从数据库中读数据中寻找若隐若现的OOP
using System.Configuration;
从数据库中读数据中寻找若隐若现的OOP
using System.Collections;
从数据库中读数据中寻找若隐若现的OOP
using System.Web;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.Security;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI.WebControls;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI.WebControls.WebParts;
从数据库中读数据中寻找若隐若现的OOP
using System.Web.UI.HtmlControls;
从数据库中读数据中寻找若隐若现的OOP
using Newtonsoft.Json;
从数据库中读数据中寻找若隐若现的OOP
从数据库中读数据中寻找若隐若现的OOP
从数据库中读数据中寻找若隐若现的OOP
public partial class Default2 : System.Web.UI.Page


相关文章: