mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update mongodb
This commit is contained in:
parent
526d6267e5
commit
b7c6dac5a6
@ -13,6 +13,7 @@ namespace MongoDbTest
|
||||
{
|
||||
QuerySingle.Init();
|
||||
QueryWhere.Init();
|
||||
QuerySelect.Init();
|
||||
}
|
||||
public static void ThrowUnitError()
|
||||
{
|
||||
|
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; }
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user