mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2026-02-27 06:03:09 +08:00
Add .NET7 Test
This commit is contained in:
14
Src/Asp.NetCore2/Net7Test/NET7Test/NET7Test/NET7Test.csproj
Normal file
14
Src/Asp.NetCore2/Net7Test/NET7Test/NET7Test/NET7Test.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\SqlSugar\SqlSugar.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
65
Src/Asp.NetCore2/Net7Test/NET7Test/NET7Test/Program.cs
Normal file
65
Src/Asp.NetCore2/Net7Test/NET7Test/NET7Test/Program.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using SqlSugar;
|
||||
|
||||
ServerTest();
|
||||
|
||||
Console.Read();
|
||||
static void MyTest()
|
||||
{
|
||||
var sqlugar = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.SqlServer,
|
||||
ConnectionString = "SERVER=.;uid=sa;pwd=sasa;database=SqlSugar4Text4"
|
||||
},
|
||||
it =>
|
||||
{
|
||||
it.Aop.OnLogExecuting = (s, p) => Console.WriteLine(s, p);
|
||||
});
|
||||
sqlugar.DbMaintenance.CreateDatabase();
|
||||
sqlugar.CodeFirst.InitTables<UnitDate01231>();
|
||||
sqlugar.Insertable(new UnitDate01231()
|
||||
{
|
||||
dateOnly = DateOnly.FromDateTime(DateTime.Now),
|
||||
timeOnly = TimeOnly.FromDateTime(DateTime.Now),
|
||||
}).ExecuteCommand();
|
||||
|
||||
|
||||
|
||||
var list = sqlugar.Queryable<UnitDate01231>().OrderByDescending(it => it.dateOnly).ToList();
|
||||
|
||||
var d1 = new UnitDate01231().dateOnly;
|
||||
var d2 = new UnitDate01231().timeOnly;
|
||||
}
|
||||
static void ServerTest()
|
||||
{
|
||||
var sqlugar = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
DbType = DbType.SqlServer,
|
||||
ConnectionString = "SERVER=.;uid=sa;pwd=sasa;database=SqlSugar4Text4"
|
||||
},
|
||||
it =>
|
||||
{
|
||||
it.Aop.OnLogExecuting = (s, p) => Console.WriteLine(s, p);
|
||||
});
|
||||
sqlugar.DbMaintenance.CreateDatabase();
|
||||
sqlugar.CodeFirst.InitTables<UnitDate01231>();
|
||||
sqlugar.Insertable(new UnitDate01231()
|
||||
{
|
||||
dateOnly = DateOnly.FromDateTime(DateTime.Now),
|
||||
timeOnly = TimeOnly.FromDateTime(DateTime.Now),
|
||||
}).ExecuteCommand();
|
||||
|
||||
|
||||
|
||||
var list = sqlugar.Queryable<UnitDate01231>().OrderByDescending(it => it.dateOnly).ToList();
|
||||
|
||||
var d1 = new UnitDate01231().dateOnly;
|
||||
var d2 = new UnitDate01231().timeOnly;
|
||||
}
|
||||
|
||||
public class UnitDate01231
|
||||
{
|
||||
[SugarColumn(ColumnDataType = "time")]
|
||||
public TimeOnly timeOnly { get; set; }
|
||||
[SugarColumn(ColumnDataType = "datetime")]
|
||||
public DateOnly dateOnly { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user