mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-25 10:19:17 +08:00
Support (date1-date2).ToTalDays hours minutes
This commit is contained in:
@@ -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" />
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
UCustom011.Init();
|
||||
UCustom010.Init();
|
||||
UCustom08.Init();
|
||||
UCustom07.Init();
|
||||
|
||||
32
Src/Asp.Net/SqlServerTest/UnitTest/UCustom011.cs
Normal file
32
Src/Asp.Net/SqlServerTest/UnitTest/UCustom011.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user