mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 12:47:57 +08:00
Add unit test
This commit is contained in:
parent
908dc7562a
commit
990d471eca
43
Src/Asp.Net/QuestDbTest/Demo/Unit01.cs
Normal file
43
Src/Asp.Net/QuestDbTest/Demo/Unit01.cs
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SqlSugar;
|
||||||
|
namespace OrmTest
|
||||||
|
{
|
||||||
|
public class Unit01
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var client = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = "host=localhost;port=8812;username=admin;password=quest;database=qdb;ServerCompatibilityMode=NoTypeLoading;",
|
||||||
|
DbType = DbType.QuestDB,
|
||||||
|
LanguageType = LanguageType.Chinese,
|
||||||
|
IsAutoCloseConnection = true
|
||||||
|
});
|
||||||
|
|
||||||
|
client.CodeFirst.InitTables<TestUserEntity>();
|
||||||
|
|
||||||
|
TestUserEntity[] users = new TestUserEntity[]
|
||||||
|
{
|
||||||
|
new TestUserEntity(){Name="zhangsan",cate="a" },
|
||||||
|
new TestUserEntity(){Name="lisi",cate="b" }
|
||||||
|
};
|
||||||
|
|
||||||
|
client.Queryable<TestUserEntity>().Where(u => u.cate.Equals("a")).ToList();
|
||||||
|
|
||||||
|
client.Queryable<TestUserEntity>().Where(u => u.cate.Equals(users[0].cate)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
[SugarTable("TestUser")]
|
||||||
|
public class TestUserEntity
|
||||||
|
{
|
||||||
|
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string cate { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,9 +25,10 @@ namespace OrmTest
|
|||||||
DemoE_CodeFirst.Init();
|
DemoE_CodeFirst.Init();
|
||||||
DemoF_Utilities.Init();
|
DemoF_Utilities.Init();
|
||||||
DemoG_SimpleClient.Init();
|
DemoG_SimpleClient.Init();
|
||||||
//Unit test
|
Unit01.Init();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Console.WriteLine("all successfully.");
|
Console.WriteLine("all successfully.");
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Config.cs" />
|
<Compile Include="Config.cs" />
|
||||||
|
<Compile Include="Demo\Unit01.cs" />
|
||||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||||
<Compile Include="Demo\Demo1_Queryable.cs" />
|
<Compile Include="Demo\Demo1_Queryable.cs" />
|
||||||
<Compile Include="Demo\Demo2_Updateable.cs" />
|
<Compile Include="Demo\Demo2_Updateable.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user