DbDataUpdate - 自动提交对象模型数据 - 常用数据类型测试
DbDataUpdate - 自动提交对象模型数据 - 常用数据类型测试
产品详情: http://www.csframework.com/cs-framework-database.htm
CSFramework.DB简介
我们在开发软件过程中,特别是基于数据管理应用相关的系统,一般采用一种数据库,如Microsoft SQL Server,超大型系统有的使用Oracle,部分Web系统采用开源的MySQL等,由于各种业务场景以及用户需求,促使我们的数据库系统部署在不同类型的数据库服务器上。若开发的系统能支持多种数据库的快速切换,可以为我们减少很多烦恼,同时提高系统的适应性、兼容性以及可扩展性。
扫一扫加微信
SQL Code:
CREATE TABLE [dbo].[_TestDbUpdateModel](
[isid] [INT] IDENTITY(1,1) NOT NULL,
[PK] [VARCHAR](50) NOT NULL,
[TestString] [VARCHAR](250) NULL,
[TestInt] [INT] NULL,
[TestDate] [DATETIME] NULL,
[TestTimestamp] [TIMESTAMP] NULL,
[TestBit] [BIT] NULL,
[TestByteArrar] [IMAGE] NULL,
[TestFloat] [FLOAT] NULL,
[TestBinary] [VARBINARY](MAX) NULL,
[TestChar] [CHAR](1) NULL,
[TestText] [TEXT] NULL,
[TestMoney] [MONEY] NULL,
[TestNumeric] [NUMERIC](18, 4) NULL,
CONSTRAINT [PK__TestDbUpdateModel] PRIMARY KEY CLUSTERED
(
[PK] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
//来源:C/S框架网 | www.csframework.com | QQ:23404761
CREATE TABLE [dbo].[_TestDbUpdateModel](
[isid] [INT] IDENTITY(1,1) NOT NULL,
[PK] [VARCHAR](50) NOT NULL,
[TestString] [VARCHAR](250) NULL,
[TestInt] [INT] NULL,
[TestDate] [DATETIME] NULL,
[TestTimestamp] [TIMESTAMP] NULL,
[TestBit] [BIT] NULL,
[TestByteArrar] [IMAGE] NULL,
[TestFloat] [FLOAT] NULL,
[TestBinary] [VARBINARY](MAX) NULL,
[TestChar] [CHAR](1) NULL,
[TestText] [TEXT] NULL,
[TestMoney] [MONEY] NULL,
[TestNumeric] [NUMERIC](18, 4) NULL,
CONSTRAINT [PK__TestDbUpdateModel] PRIMARY KEY CLUSTERED
(
[PK] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
//来源:C/S框架网 | www.csframework.com | QQ:23404761
C# Code:
///<summary>
/// ORM模型, 数据表:_TestDbUpdateModel,由ClassGenerator自动生成
/// </summary>
public class _TestDbUpdateModel
{
#region 所有字段属性
public int isid { get; set; }
public string PK { get; set; }
public string TestString { get; set; }
public int TestInt { get; set; }
public DateTime TestDate { get; set; }
public DateTime TestTimestamp { get; set; }
public bool TestBit { get; set; }
public Byte[] TestByteArrar { get; set; }
public Double TestFloat { get; set; }
public Byte[] TestBinary { get; set; }
public string TestChar { get; set; }
public string TestText { get; set; }
public Single TestMoney { get; set; }
public Decimal TestNumeric { get; set; }
#endregion
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
/// ORM模型, 数据表:_TestDbUpdateModel,由ClassGenerator自动生成
/// </summary>
public class _TestDbUpdateModel
{
#region 所有字段属性
public int isid { get; set; }
public string PK { get; set; }
public string TestString { get; set; }
public int TestInt { get; set; }
public DateTime TestDate { get; set; }
public DateTime TestTimestamp { get; set; }
public bool TestBit { get; set; }
public Byte[] TestByteArrar { get; set; }
public Double TestFloat { get; set; }
public Byte[] TestBinary { get; set; }
public string TestChar { get; set; }
public string TestText { get; set; }
public Single TestMoney { get; set; }
public Decimal TestNumeric { get; set; }
#endregion
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
C# Code:
private void button14_Click(object sender, EventArgs e)
{
//DbDataUpdate - 自动提交对象模型数据 - 常用数据类型测试
_TestDbUpdateModel m = new _TestDbUpdateModel
{
PK = Guid.NewGuid().ToString(), // "记录主键值",
isid = 0,
TestBinary = new byte[] { 1, 2, 3, 4, 5, 6, 7 },
TestBit = true,
TestByteArrar = new byte[] { 1, 2, 3, 4, 5, 6, 7 },
TestChar = "a",
TestDate = DateTime.Now,
TestFloat = 1234.5678f,// float.Parse("1234.5678"),
TestInt = 1234,
TestMoney = 1234.34f,
TestNumeric = 1234.4567m, //decimal.Parse("1234.4567"),
TestString = "CSFramework.DbDataUpdate(自动提交对象模型数据)数据类型测试",
TestText = "CSFramework.DbDataUpdate(自动提交对象模型数据)数据类型测试",
TestTimestamp = DateTime.Now,//MsSQL数据库字段类型timeStamp应对应.net类型DateTime
};
string conn = "Data Source=127.0.0.1;Initial Catalog=CSFrameworkV5_System;User ID=sa;Password =test;Persist Security Info=True;Connect Timeout=15;";
IDatabase db = DatabaseFactory.CreateDatabase(DatabaseType.SqlServer, conn);
DbDataUpdate update = new DbDataUpdate(db);
//测试新增记录
string[] fields = new string[] { "isid", "TestTimestamp" };
bool b1 = update.AddObject<_TestDbUpdateModel>(m, fields);
ShowResult(b1);
//测试修改
m.TestText = m.TestText + "修改";
bool b2 = update.UpdateObject<_TestDbUpdateModel>(m, new string[] { "PK" }, fields);
ShowResult(b2);
//测试删除
bool b3 = update.DeleteObject<_TestDbUpdateModel>(m, new string[] { "PK" });
ShowResult(b3);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
private void button14_Click(object sender, EventArgs e)
{
//DbDataUpdate - 自动提交对象模型数据 - 常用数据类型测试
_TestDbUpdateModel m = new _TestDbUpdateModel
{
PK = Guid.NewGuid().ToString(), // "记录主键值",
isid = 0,
TestBinary = new byte[] { 1, 2, 3, 4, 5, 6, 7 },
TestBit = true,
TestByteArrar = new byte[] { 1, 2, 3, 4, 5, 6, 7 },
TestChar = "a",
TestDate = DateTime.Now,
TestFloat = 1234.5678f,// float.Parse("1234.5678"),
TestInt = 1234,
TestMoney = 1234.34f,
TestNumeric = 1234.4567m, //decimal.Parse("1234.4567"),
TestString = "CSFramework.DbDataUpdate(自动提交对象模型数据)数据类型测试",
TestText = "CSFramework.DbDataUpdate(自动提交对象模型数据)数据类型测试",
TestTimestamp = DateTime.Now,//MsSQL数据库字段类型timeStamp应对应.net类型DateTime
};
string conn = "Data Source=127.0.0.1;Initial Catalog=CSFrameworkV5_System;User ID=sa;Password =test;Persist Security Info=True;Connect Timeout=15;";
IDatabase db = DatabaseFactory.CreateDatabase(DatabaseType.SqlServer, conn);
DbDataUpdate update = new DbDataUpdate(db);
//测试新增记录
string[] fields = new string[] { "isid", "TestTimestamp" };
bool b1 = update.AddObject<_TestDbUpdateModel>(m, fields);
ShowResult(b1);
//测试修改
m.TestText = m.TestText + "修改";
bool b2 = update.UpdateObject<_TestDbUpdateModel>(m, new string[] { "PK" }, fields);
ShowResult(b2);
//测试删除
bool b3 = update.DeleteObject<_TestDbUpdateModel>(m, new string[] { "PK" });
ShowResult(b3);
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
CSFramework.DB数据库底层应用框架 v2.0
适用软件:基于C#.NET开发的C/S系统、WebApi后端、Winform桌面应用软件。
运行平台:Windows + .NET Framework 4.5
开发工具:Visual Studio 2015,C#语言
数据库支持:MsSQL+Oracle+MySQL
运行平台:Windows + .NET Framework 4.5
开发工具:Visual Studio 2015,C#语言
数据库支持:MsSQL+Oracle+MySQL
产品详情: http://www.csframework.com/cs-framework-database.htm
CSFramework.DB简介
我们在开发软件过程中,特别是基于数据管理应用相关的系统,一般采用一种数据库,如Microsoft SQL Server,超大型系统有的使用Oracle,部分Web系统采用开源的MySQL等,由于各种业务场景以及用户需求,促使我们的数据库系统部署在不同类型的数据库服务器上。若开发的系统能支持多种数据库的快速切换,可以为我们减少很多烦恼,同时提高系统的适应性、兼容性以及可扩展性。
扫一扫加微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网