mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 10:08:19 +08:00
Update demo
This commit is contained in:
@@ -38,7 +38,7 @@ namespace MongoDbTest
|
|||||||
Unitdafasdys.Init();
|
Unitdafasdys.Init();
|
||||||
Enum.Init();
|
Enum.Init();
|
||||||
Enum2.Init();
|
Enum2.Init();
|
||||||
|
UnitDateTimeFunc.Init();
|
||||||
//主键不是ObjectId类型用例
|
//主键不是ObjectId类型用例
|
||||||
//The primary key is not an ObjectId type use case
|
//The primary key is not an ObjectId type use case
|
||||||
LongPrimaryKey.Init();
|
LongPrimaryKey.Init();
|
||||||
|
40
Src/Asp.NetCore2/MongoDbTest/UnitTest/UnitDateTimeFunc.cs
Normal file
40
Src/Asp.NetCore2/MongoDbTest/UnitTest/UnitDateTimeFunc.cs
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
using SqlSugar.MongoDb;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MongoDbTest
|
||||||
|
{
|
||||||
|
internal class UnitDateTimeFunc
|
||||||
|
{
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
var db = DbHelper.GetNewDb();
|
||||||
|
db.DbMaintenance.TruncateTable<Student>();//清空重置
|
||||||
|
db.Insertable(new Student() { Name = "error time", Bool = true, CreateDateTime = DateTime.Parse("2025-09-15 00:00:01") }).ExecuteCommand();
|
||||||
|
db.Insertable(new Student() { Name = "OK time", Bool = true, CreateDateTime = DateTime.Parse("2025-09-16 00:00:01") }).ExecuteCommand();
|
||||||
|
db.Insertable(new Student() { Name = "error time2", Bool = true, CreateDateTime = DateTime.Parse("2025-09-17 00:00:01") }).ExecuteCommand();
|
||||||
|
|
||||||
|
var list1 = db.Queryable<Student>().Where(a => a.CreateDateTime >= DateTime.Parse("2025-09-16 00:00:00") && a.CreateDateTime <= DateTime.Parse("2025-09-16 23:59:59")).ToList();
|
||||||
|
if (list1.First().Name != "OK time") Cases.ThrowUnitError();
|
||||||
|
|
||||||
|
var list2=db.Queryable<Student>().Where(a => DateTime.Parse("2025-09-16 00:00:00")<=a.CreateDateTime && a.CreateDateTime <= DateTime.Parse("2025-09-16 23:59:59")).ToList();
|
||||||
|
if (list2.First().Name!= "OK time") Cases.ThrowUnitError();
|
||||||
|
}
|
||||||
|
[SqlSugar.SugarTable("UnitStudent1ssss23s131")]
|
||||||
|
public class Student : MongoDbBase
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public bool Bool { get; set; }
|
||||||
|
public bool? BoolNull { get; set; }
|
||||||
|
|
||||||
|
public int SchoolId { get; set; }
|
||||||
|
public int? SchoolIdNull { get; set; }
|
||||||
|
|
||||||
|
public DateTime CreateDateTime { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user