mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-21 02:58:05 +08:00
Add demo
This commit is contained in:
38
Src/Asp.NetCore2/MongoDbTest/UnitTest/QueryJsonArray3.cs
Normal file
38
Src/Asp.NetCore2/MongoDbTest/UnitTest/QueryJsonArray3.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
using SqlSugar;
|
||||
using SqlSugar.MongoDb;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MongoDbTest
|
||||
{
|
||||
public class QueryJsonArray3
|
||||
{
|
||||
internal static void Init()
|
||||
{
|
||||
var db = DbHelper.GetNewDb();
|
||||
db.CodeFirst.InitTables<Student>();
|
||||
db.DbMaintenance.TruncateTable<Student>();
|
||||
db.Insertable(new Student() { Book = new double[] { 1, 2.1, 3 } }).ExecuteCommand();
|
||||
var list = db.Queryable<Student>().ToList();
|
||||
if (list.First().Book[1] != 2.1) Cases.ThrowUnitError();
|
||||
list.First().Book[1] = 2.2;
|
||||
db.Updateable(list).ExecuteCommand();
|
||||
var list2 = db.Queryable<Student>().ToList();
|
||||
if (list2.First().Book[1] != 2.2) Cases.ThrowUnitError();
|
||||
}
|
||||
|
||||
[SqlSugar.SugarTable("UnitStudentds79991")]
|
||||
public class Student : MongoDbBase
|
||||
{
|
||||
public string Name { get; set; }
|
||||
|
||||
[SqlSugar.SugarColumn(IsJson = true)]
|
||||
public double[] Book { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user