Support (date1-date2).ToTalDays hours minutes

This commit is contained in:
sunkaixuan
2022-03-23 10:32:39 +08:00
parent af39446253
commit ebe0a7b31b
4 changed files with 87 additions and 0 deletions

View File

@@ -100,6 +100,7 @@
<Compile Include="UnitTest\Models\UserEntity.cs" />
<Compile Include="UnitTest\Models\UserRoleEntity.cs" />
<Compile Include="UnitTest\UCustom01.cs" />
<Compile Include="UnitTest\UCustom011.cs" />
<Compile Include="UnitTest\UCustom02.cs" />
<Compile Include="UnitTest\UCustom03.cs" />
<Compile Include="UnitTest\UCustom010.cs" />

View File

@@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
UCustom011.Init();
UCustom010.Init();
UCustom08.Init();
UCustom07.Init();

View File

@@ -0,0 +1,32 @@
using OrmTest.UnitTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UCustom011
{
public static void Init()
{
var db = NewUnitTest.Db;
db.Queryable<Order>().Where(it => (it.CreateTime - SqlFunc.GetDate()).TotalDays > 1).ToList();
var x1=db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddYears(-1)).TotalDays).ToList();
var x2 = db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddDays(-1)).TotalHours).ToList();
var x3 = db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddHours(-1)).TotalMinutes).ToList();
var x4 = db.Queryable<Order>().Select(it => (DateTime.Now - SqlFunc.GetDate().AddMinutes(-1)).TotalSeconds).ToList();
if (x1.Any())
{
Check.Exception(x1.First()!=365, "unit error . UCustom011");
Check.Exception(x2.First() != 24, "unit error . UCustom011");
Check.Exception(x3.First() != 60, "unit error . UCustom011");
Check.Exception(x4.First() != 60, "unit error . UCustom011");
}
}
}
}