mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Update mongdob
This commit is contained in:
@@ -20,6 +20,7 @@ namespace MongoDbTest
|
||||
QueryLeftJoin2.Init();
|
||||
QueryJsonArray.Init();
|
||||
Insert.Init();
|
||||
Insert2.Init();
|
||||
Update.Init();
|
||||
Delete.Init();
|
||||
InsertOrUpdate.Init();
|
||||
|
37
Src/Asp.NetCore2/MongoDbTest/UnitTest/Insert2.cs
Normal file
37
Src/Asp.NetCore2/MongoDbTest/UnitTest/Insert2.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
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 Insert2
|
||||
{
|
||||
internal static void Init()
|
||||
{
|
||||
var db = DbHelper.GetNewDb();
|
||||
db.CodeFirst.InitTables<Student>();
|
||||
db.DbMaintenance.TruncateTable<Student>();
|
||||
|
||||
//Get primary key
|
||||
var data = new Student() { Age = 1, Name = "11", SchoolId = "111" };
|
||||
db.Insertable(data).ExecuteCommandIdentityIntoEntity();
|
||||
var data2=db.Queryable<Student>().ToList();
|
||||
|
||||
}
|
||||
[SqlSugar.SugarTable("UnitStudentadsfe2s3z1")]
|
||||
public class Student : MongoDbBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
public string SchoolId { get; set; }
|
||||
|
||||
public int Age { get; set; }
|
||||
[SqlSugar.SugarColumn(InsertServerTime =true)]
|
||||
public DateTime CreateDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user