mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
-
This commit is contained in:
parent
59ae02625a
commit
b6a57b3614
Binary file not shown.
135
SqlServerTest/Models/DataTestInfo.cs
Normal file
135
SqlServerTest/Models/DataTestInfo.cs
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OrmTest.Models
|
||||||
|
{
|
||||||
|
///<summary>
|
||||||
|
///
|
||||||
|
///</summary>
|
||||||
|
public class DataTestInfo
|
||||||
|
{
|
||||||
|
public DataTestInfo(){
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public int Int1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public int? Int2 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public string String {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public decimal Decimal1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public decimal? Decimal2 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public DateTime Datetime1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? Datetime2 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public byte[] Image1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public byte[] Image2 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public Guid Guid1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public Guid? Guid2 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public decimal Money1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public decimal? Money2 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public byte[] Varbinary1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public byte[] Varbinary2 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
public double Float1 {get;set;}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:True
|
||||||
|
/// </summary>
|
||||||
|
public double? Float2 {get;set;}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -29,7 +29,7 @@ namespace OrmTest
|
|||||||
new Delete(1).Init();
|
new Delete(1).Init();
|
||||||
new Update(1).Init();
|
new Update(1).Init();
|
||||||
new Mapping(1).Init();
|
new Mapping(1).Init();
|
||||||
|
new DataTest(1).Init();
|
||||||
/***Performance Test***/
|
/***Performance Test***/
|
||||||
new SqlSugarPerformance(100).Select();
|
new SqlSugarPerformance(100).Select();
|
||||||
|
|
||||||
|
@ -54,9 +54,11 @@
|
|||||||
<Compile Include="Demos\Insert.cs" />
|
<Compile Include="Demos\Insert.cs" />
|
||||||
<Compile Include="Demos\Query.cs" />
|
<Compile Include="Demos\Query.cs" />
|
||||||
<Compile Include="Demos\Update.cs" />
|
<Compile Include="Demos\Update.cs" />
|
||||||
|
<Compile Include="Models\DataTestInfo.cs" />
|
||||||
<Compile Include="Models\ViewModelStudent.cs" />
|
<Compile Include="Models\ViewModelStudent.cs" />
|
||||||
<Compile Include="PerformanceTesting\PerformanceBase.cs" />
|
<Compile Include="PerformanceTesting\PerformanceBase.cs" />
|
||||||
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
|
<Compile Include="PerformanceTesting\SqlSugarPerformance.cs" />
|
||||||
|
<Compile Include="UnitTest\DataTest.cs" />
|
||||||
<Compile Include="UnitTest\Delete.cs" />
|
<Compile Include="UnitTest\Delete.cs" />
|
||||||
<Compile Include="UnitTest\UnitTestBase.cs" />
|
<Compile Include="UnitTest\UnitTestBase.cs" />
|
||||||
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
<Compile Include="UnitTest\ExpressionTest\Field.cs" />
|
||||||
|
51
SqlServerTest/UnitTest/DataTest.cs
Normal file
51
SqlServerTest/UnitTest/DataTest.cs
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
using OrmTest.Models;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OrmTest.UnitTest
|
||||||
|
{
|
||||||
|
public class DataTest : UnitTestBase
|
||||||
|
{
|
||||||
|
private DataTest() { }
|
||||||
|
public DataTest(int eachCount)
|
||||||
|
{
|
||||||
|
this.Count = eachCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
|
var db = GetInstance();
|
||||||
|
db.DbMaintenance.TruncateTable("DataTestInfo");
|
||||||
|
var insertObject = new DataTestInfo()
|
||||||
|
{
|
||||||
|
Datetime1 = DateTime.Now,
|
||||||
|
Datetime2 = DateTime.Now,
|
||||||
|
Decimal1 = 1,
|
||||||
|
Decimal2 = 2,
|
||||||
|
Float1 = 3,
|
||||||
|
Float2 = 4,
|
||||||
|
Guid1 = Guid.Empty,
|
||||||
|
Guid2 = null,
|
||||||
|
Image1 = new byte[] { 1, 2 },
|
||||||
|
Image2 = new byte[] { 2, 3 },
|
||||||
|
Int1 = 5,
|
||||||
|
Int2 = 6,
|
||||||
|
Money1 = 7,
|
||||||
|
Money2 = 8,
|
||||||
|
Varbinary1 = new byte[] { 4, 5 },
|
||||||
|
Varbinary2 = null,
|
||||||
|
String = "string"
|
||||||
|
};
|
||||||
|
var id = db.Insertable<DataTestInfo>(insertObject).ExecuteReutrnIdentity();
|
||||||
|
var data = db.Queryable<DataTestInfo>().InSingle(id);
|
||||||
|
}
|
||||||
|
public SqlSugarClient GetInstance()
|
||||||
|
{
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true });
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -72,7 +72,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public virtual bool TruncateTable(string tableName)
|
public virtual bool TruncateTable(string tableName)
|
||||||
{
|
{
|
||||||
this.Context.Ado.ExecuteCommand(this.TruncateTableSql);
|
this.Context.Ado.ExecuteCommand(string.Format(this.TruncateTableSql,tableName));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user