JDML,原来做数据库应用可以如此简单!
JDML是一个小工具,小Library。
主要用于通过创建poco,然后自动根据poco类创建数据库
方便用户开发CRUD应用!
功能如下:
1。根据Class类,生成对应的数据库表
先写好类的代码:
1 [Table(TableName = "Customer_Source")]
2 public class CustomerSource
3 {
4 [Field(FieldName = "Customer_Source_ID", PrimaryKey = true, AutoGenerate = true)]
5 public int? ID { get; set; }
6 public string Name { get; set; }
7 public string Remark { get; set; }
8 public DateTime? CreateOn { get; set; }
9 public DateTime? ModifyOn { get; set; }
10 }
然后执行:
(new CustomerSource()).CreateTable();
直接自动生成表:
2。插入数据:
Customer_Source source = new Customer_Source();
source.Name = "旅行社";
source.Remark = "旅行社协议客户";
source.Insert();
就在表中插入如下数据:
3。修改数据:
Customer_Source source = new Customer_Source() { ID = 1 };
source.Load();
source.Name = "携程网";
source.Remark = "携程网用户";
source.Update();
或者:
Customer_Source source = new Customer_Source() { Name = "旅行社" };
source.Find();
source.Name = "携程网";
source.Remark = "携程网用户";
source.Update();
修改后的数据:
4。删除数据:
Customer_Source source = new Customer_Source() { Name = "携程网" };
source.Find();
source.Delete();
数据被删除:
JDML的代码,以及测试的DEMO,尽在
Q Q 85302520, 技术丶设计 QQ讨论群: 33382182
邮 箱:gongji@qq.com
欢迎与我探讨技术问题!