mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 04:35:29 +08:00
Update mongodb
This commit is contained in:
parent
baab313f06
commit
ff179a28c8
@ -14,6 +14,9 @@ namespace MongoDbTest
|
||||
QuerySingle.Init();
|
||||
QueryWhere.Init();
|
||||
QuerySelect.Init();
|
||||
Insert.Init();
|
||||
Update.Init();
|
||||
Delete.Init();
|
||||
}
|
||||
public static void ThrowUnitError()
|
||||
{
|
||||
|
30
Src/Asp.NetCore2/MongoDbTest/UnitTest/Delete.cs
Normal file
30
Src/Asp.NetCore2/MongoDbTest/UnitTest/Delete.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using SqlSugar.MongoDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MongoDbTest
|
||||
{
|
||||
public class Delete
|
||||
{
|
||||
internal static void Init()
|
||||
{
|
||||
var db = DBHelper.DbHelper.GetNewDb();
|
||||
db.CodeFirst.InitTables<Student>();
|
||||
db.DbMaintenance.TruncateTable<Student>();
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitStudent1ssdds3z1")]
|
||||
public class Student : MongoDbBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string SchoolId { get; set; }
|
||||
|
||||
public int Age { get; set; }
|
||||
|
||||
public DateTime CreateDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
41
Src/Asp.NetCore2/MongoDbTest/UnitTest/Insert.cs
Normal file
41
Src/Asp.NetCore2/MongoDbTest/UnitTest/Insert.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using SqlSugar.MongoDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MongoDbTest
|
||||
{
|
||||
public class Insert
|
||||
{
|
||||
internal static void Init()
|
||||
{
|
||||
var db = DBHelper.DbHelper.GetNewDb();
|
||||
db.CodeFirst.InitTables<Student>();
|
||||
db.DbMaintenance.TruncateTable<Student>();
|
||||
|
||||
db.Insertable(new Student() { Age = 1, Name = "11", SchoolId = "111", CreateDateTime = DateTime.Now }).ExecuteCommand();
|
||||
db.Insertable(new List<Student>() {
|
||||
new Student() { Age = 2, Name = "22", SchoolId = "222", CreateDateTime = DateTime.Now },
|
||||
new Student() { Age = 3, Name = "33", SchoolId = "333", CreateDateTime = DateTime.Now }
|
||||
}).ExecuteCommand();
|
||||
|
||||
if (db.Queryable<Student>().Count() != 3) Cases.ThrowUnitError();
|
||||
var list=db.Queryable<Student>().ToList();
|
||||
if (list.First().Name!="11"|| list.Last().Name != "33") Cases.ThrowUnitError();
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitStudent1ddsfhssds3z1")]
|
||||
public class Student : MongoDbBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string SchoolId { get; set; }
|
||||
|
||||
public int Age { get; set; }
|
||||
|
||||
public DateTime CreateDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
30
Src/Asp.NetCore2/MongoDbTest/UnitTest/Update.cs
Normal file
30
Src/Asp.NetCore2/MongoDbTest/UnitTest/Update.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using SqlSugar.MongoDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MongoDbTest
|
||||
{
|
||||
public class Update
|
||||
{
|
||||
internal static void Init()
|
||||
{
|
||||
var db = DBHelper.DbHelper.GetNewDb();
|
||||
db.CodeFirst.InitTables<Student>();
|
||||
db.DbMaintenance.TruncateTable<Student>();
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitStudentdghhuesd3z1")]
|
||||
public class Student : MongoDbBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string SchoolId { get; set; }
|
||||
|
||||
public int Age { get; set; }
|
||||
|
||||
public DateTime CreateDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user