From 19f191de56ef1cbbff77fb342ebe45f8b1b0423b Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 29 Jul 2025 09:20:39 +0800 Subject: [PATCH] Addd demo --- .../MongoDbTest/UnitTest/Cases.cs | 1 + .../MongoDbTest/UnitTest/Enum2.cs | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 Src/Asp.NetCore2/MongoDbTest/UnitTest/Enum2.cs diff --git a/Src/Asp.NetCore2/MongoDbTest/UnitTest/Cases.cs b/Src/Asp.NetCore2/MongoDbTest/UnitTest/Cases.cs index 30ec3c514..aa33f4c50 100644 --- a/Src/Asp.NetCore2/MongoDbTest/UnitTest/Cases.cs +++ b/Src/Asp.NetCore2/MongoDbTest/UnitTest/Cases.cs @@ -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 diff --git a/Src/Asp.NetCore2/MongoDbTest/UnitTest/Enum2.cs b/Src/Asp.NetCore2/MongoDbTest/UnitTest/Enum2.cs new file mode 100644 index 000000000..942c750dd --- /dev/null +++ b/Src/Asp.NetCore2/MongoDbTest/UnitTest/Enum2.cs @@ -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(); + db.DbMaintenance.TruncateTable(); + db.Insertable(new Student() { type = DbType.Tidb }).ExecuteCommand(); + if (db.Queryable().First().type != DbType.Tidb) Cases.Init(); + if (db.Queryable().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; } + } + } +}