mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-21 02:58:05 +08:00
Update mongodb
This commit is contained in:
38
Src/Asp.NetCore2/MongoDbTest/UnitTest/QuerySelect.cs
Normal file
38
Src/Asp.NetCore2/MongoDbTest/UnitTest/QuerySelect.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user