mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Add user test case
This commit is contained in:
parent
ce1c897ce8
commit
9564d27fa1
@ -7,6 +7,7 @@ namespace SqliteTest.UnitTest
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
Unitadfadsyyy.Init();
|
||||
//Demo
|
||||
Demo0_SqlSugarClient.Init();
|
||||
Demo1_Queryable.Init();
|
||||
|
73
Src/Asp.NetCore2/SqliteTest/UserTestCases/Unitadfadf1.cs
Normal file
73
Src/Asp.NetCore2/SqliteTest/UserTestCases/Unitadfadf1.cs
Normal file
@ -0,0 +1,73 @@
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public class Unitadfadsyyy
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = new SqlSugarScope(new List<ConnectionConfig>()
|
||||
{
|
||||
new()
|
||||
{
|
||||
ConfigId = "Main",
|
||||
ConnectionString = $@"DataSource={Environment.CurrentDirectory}\test12.db",
|
||||
DbType = DbType.Sqlite,
|
||||
IsAutoCloseConnection = true
|
||||
}
|
||||
}, client => { client.Aop.OnLogExecuting = (s, parameters) => Console.WriteLine(s); });
|
||||
|
||||
db.CodeFirst.InitTables<Student1231231, StarStudent12313131>();
|
||||
|
||||
var list=db.Queryable<Student1231231>()
|
||||
.IncludeLeftJoin(s => s.StartStudent)
|
||||
.Where(s => s.Name.StartsWith("张"))
|
||||
.Select(s => new StudentDto()
|
||||
{
|
||||
StarLevel = s.StartStudent.StarLevel,
|
||||
},true)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public class Student1231231
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
|
||||
public string Age { get; set; }
|
||||
|
||||
public string Phone { get; set; }
|
||||
public string Address { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(Id), nameof(StarStudent12313131.StudentId))]
|
||||
public StarStudent12313131 StartStudent { get; set; }
|
||||
}
|
||||
|
||||
public class StarStudent12313131
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int StudentId { get; set; }
|
||||
|
||||
public int StarLevel { get; set; }
|
||||
}
|
||||
|
||||
public class StudentDto
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Age { get; set; }
|
||||
|
||||
public string Phone { get; set; }
|
||||
public string Address { get; set; }
|
||||
|
||||
public int StarLevel { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user