Addd demo

This commit is contained in:
sunkaixuan
2025-07-29 09:20:39 +08:00
parent a4892bea1b
commit 19f191de56
2 changed files with 31 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ namespace MongoDbTest
InsertOrUpdate.Init();
Unitdafasdys.Init();
Enum.Init();
Enum2.Init();
//主键不是ObjectId类型用例
//The primary key is not an ObjectId type use case

View File

@@ -0,0 +1,30 @@
using SqlSugar;
using SqlSugar.MongoDb;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MongoDbTest
{
internal class Enum2
{
public static void Init()
{
var db = DbHelper.GetNewDb();
db.CodeFirst.InitTables<Student>();
db.DbMaintenance.TruncateTable<Student>();
db.Insertable(new Student() { type = DbType.Tidb }).ExecuteCommand();
if (db.Queryable<Student>().First().type != DbType.Tidb) Cases.Init();
if (db.Queryable<Student>().Where(s=>s.type==DbType.Tidb).First().type != DbType.Tidb) Cases.Init();
}
[SqlSugar.SugarTable("UnitStudentadsdujj3z1")]
public class Student : MongoDbBase
{
//存储string枚举
[SugarColumn(SqlParameterDbType =typeof(SqlSugar.DbConvert.EnumToStringConvert))]
public DbType type { get; set; }
}
}
}