Update mongodb

This commit is contained in:
sunkaixuan 2025-06-14 13:12:48 +08:00
parent 526d6267e5
commit b7c6dac5a6
3 changed files with 40 additions and 1 deletions

View File

@ -13,6 +13,7 @@ namespace MongoDbTest
{
QuerySingle.Init();
QueryWhere.Init();
QuerySelect.Init();
}
public static void ThrowUnitError()
{

View File

@ -0,0 +1,38 @@
using MongoDB.Bson;
using MongoDB.Driver;
using MongoDbTest.DBHelper;
using SqlSugar.MongoDb;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MongoDbTest
{
public class QuerySelect
{
internal static void Init()
{
var db = DBHelper.DbHelper.GetNewDb();
db.CodeFirst.InitTables<Student>(); ;
var dt = DateTime.Now;
var studentId = db.Insertable(new Student() { CreateDateTime=dt, Name="a", SchoolId="aa" })
.ExecuteCommand();
var list=db.Queryable<Student>().Select(it => new
{
date=it.CreateDateTime.Date
}).ToList();
if (list.First().date != dt.Date) Cases.ThrowUnitError();
}
[SqlSugar.SugarTable("UnitStudent1231sds3z1")]
public class Student : MongoDbBase
{
public string Name { get; set; }
public string SchoolId { get; set; }
public DateTime CreateDateTime { get; set; }
}
}
}

View File

@ -2,7 +2,7 @@
<package >
<metadata>
<id>SqlSugarCore</id>
<version>5.1.4.196</version>
<version>5.1.4.197-preview04</version>
<authors>sunkaixuan</authors>
<owners>果糖大数据科技</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>