Files
SqlSugar/Src/Asp.NetCore2/MongoDbTest/UnitTest/QueryJson3.cs

45 lines
1.2 KiB
C#
Raw Normal View History

2025-08-08 15:53:06 +08:00

using SqlSugar;
2025-08-08 15:51:59 +08:00
namespace MongoDbTest
{
2025-08-08 15:53:06 +08:00
public class QueryJson3
2025-08-08 15:51:59 +08:00
{
2025-08-08 15:53:06 +08:00
public static void Init()
2025-08-08 15:51:59 +08:00
{
2025-08-08 15:53:06 +08:00
var db = DbHelper.GetNewDb();
db.DbMaintenance.TruncateTable<NoticeEntity>();
db.Insertable<NoticeEntity>(new NoticeEntity() { Id = 12312312L, NoticeTitle = "88888", noticeContentInfos = new List<NoticeContentInfo>() { new NoticeContentInfo { SubjectId = 1 } } }).ExecuteCommand();
var da = db.Updateable<NoticeEntity>()
.SetColumns(it => new NoticeEntity { NoticeTitle = "66666" }, true).Where(it => it.Id == 12312312L)
.ExecuteCommand() > 0;
2025-08-08 15:51:59 +08:00
}
}
2025-08-08 15:53:06 +08:00
}
/// <summary>
/// 通知公告
/// </summary>
[SugarTable("NoticeInfoComponent")]
public class NoticeEntity
{
[SugarColumn(ColumnName = "_id")]
public long Id { get; set; }
/// <summary>
/// 通知公告标题
/// </summary>
public string NoticeTitle { get; set; } = null!;
/// <summary>
/// 通知公告内容
/// </summary>
[SugarColumn(IsJson = true)]
public List<NoticeContentInfo> noticeContentInfos { get; set; } = null!;
}
2025-08-08 15:51:59 +08:00
2025-08-08 15:53:06 +08:00
public class NoticeContentInfo
{
/// <summary>
/// 模块
/// </summary>
public int SubjectId { get; set; }
2025-08-08 15:51:59 +08:00
}