subsonic增删改查


//直接执行sql语句查询数据,返回DataTable 

 DataTable dt;
                            QueryCommand qc = new QueryCommand(strSql.ToString(), null);
                            dt =DataService.GetDataSet(qc).Tables[0];

                            gvwzh.DataSource = dt;
                            gvwzh.DataBind();    

 

 

 1  //查询
 2 
 3         //第一种方法
 4         BaseUserController items = new BaseUserController();
 5         grw.DataSource = items.FetchAll();
 6         grw.DataBind();
 7 
 8         //第二种方法
 9         grw.DataSource = DB.Select().From(BaseUser.Schema).ExecuteDataSet().Tables[0];
10         grw.DataBind();
11 
12 
13 
14         //增加
15         BaseUser bu = new BaseUser();
16         bu.MarkNew();
17         bu.Jmsfzh = "ggggggggg";
18         bu.Dlid = "eeee";
19         bu.Xm = "eeeee";
20         bu.Pwd = "eeeeee==";//默认密码“111111”
21         bu.Sfdy = true;
22         bu.Bmid = "eeeeeeee";
23         bu.Save();
24 
25 
26         //修改
27         int result = new Update(BaseUser.Schema)
28         .Set(BaseUser.Columns.Jmsfzh).EqualTo("55555555555")
29         .Where(BaseUser.Columns.Dlid).IsEqualTo("eeee")
30         .Execute();
31 
32 
33         //删除
34         DB.Delete().From(BaseUser.Schema).Where(BaseUser.Columns.Dlid).IsEqualTo("aaaaa").Execute();

 

posted @ 2013-06-08 15:50  哪啊哪啊神去村  阅读(248)  评论(0编辑  收藏  举报