![]() | CYQ.Data componentsCYQ.Data support multi-database application [Txt,Xml,Access, MSSQL, Oracle,SQLite,MySql], help easily and quickly to develop your project |
CYQ.Data 支持传统ORM访问方式示例演示
Guide |
|
|
| #TopicOwner |
CYQ.Data 支持传统ORM访问方式示例演示 1:实体类UsersDemo继承CYQ.Data.Orm.OrmBase public class UsersDemo :CYQ.Data.Orm.OrmBase
{ public UsersDemo() { base.SetInit(this, "Users", "Conn"); } public int ID{get;set} public string UserName{get;set;}
public string Password{get;set;}
} 说明:任意实体类,只需要满足以下两点即可拥有ORM功能: 1:需要继承基类:CYQ.Data.Orm.OrmBase
2:需要在构造函数初始化: base.SetInit(this,"表名","数据库链接字符串/链接配置名称/为空时默认为Conn配置项"); 2:编写代码演示[添加/更新/删除/查询/列表查询与绑定] protected void Page_Load(object sender, EventArgs e) { UsersDemo myUser = new UsersDemo(); myUser.UserName = "路过秋天-博客园"; myUser.Password = "http://cyq1162.cnblogs.com"; myUser.Insert();//插入一条数据 myUser.Password = "我更改了密码"; myUser.Update(); myUser.Delete(17);//删除id=17的数据 if (myUser.Fill(9))//单数据填充 { Response.Write(myUser.UserName); } myUser.Select().Bind(gvUsers);//查询Users表所有数据并绑定到GrivdView控件 List<UsersDemo> entityList = myUser.Select().ToList<UsersDemo>(); gvUsers2.DataSource = entityList;//转泛型再绑定 gvUsers2.DataBind(); } 3:结果演示
a:原来表数据 b:操作后结果数据 ![]() |
游客[注册][168.160.99.*]2012/8/28 12:41:40 | #1 | |
![]() | 未将对象引用设置到对象的实例。 为什么我老是报这个错,是因为实体字段数据类型不对吗? 实体中的属性名是否需要和数据库中字段名一样? 为什么查询结果无法填充到实体里面去? 我使用的是asp.net mvc reply: 实体的属性名需要和数据库字段名一样。 |
Post Comment
Bulletin
Article Search
Categories
- Platform for dynamic (20)
- Feedback (9)
- Guide (33)
- Principles (19)
- Project-Case (8)
- Business & Buy (2)
- Technology exchange (45)
New Article
- CYQ.Data Components Getting Started Guide [Part 5]-[MProc Execute Stored Procedures or SQL]
- CYQ.Data Components Getting Started Guide [Part 4]-[MAction Insert Delete Update]
- CYQ.Data Components Getting Started Guide [Part 3]-[MAction Get And Set Value]
- CYQ.Data Components Getting Started Guide [Part 2]-[MAction Data Query- Fill And Select]
- CYQ.Data Components Getting Started Guide [Part 1]
New Comment
- When some one searches for his necessary thing, therefore he/she wishes to be available that in detail, so that thing is maintained over here.
- This is my first time pay a quick visit at here and i am in fact happy to read everthing at alone place.
- I truly appreciate this blog article.Really thank you! Cool.
- please pay a visit to the web sites we follow, like this one particular, as it represents our picks in the web
- Really enjoyed this post.Really thank you!
- Really enjoyed this article.Really looking forward to read more. Great.
- poker bonuses What are the norms of copyright of web content? How as it different from Patent?
- Wow! Thank you! I permanently needed to write on my blog something like that. Can I implement a fragment of your post to my site?
- This website was how do I say it? Relevant!! Finally I ave found something that helped me. Cheers!
- I was reading through some of your content on this internet site and I believe this web site is very informative ! Continue posting.