mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Add json index
This commit is contained in:
parent
e9971e1425
commit
e227e2f8a6
@ -63,8 +63,25 @@ namespace OrmTest
|
||||
var list31 = db.Queryable<OrderAarray11>().ToList();
|
||||
var list3=db.Queryable<OrderMain11>().LeftJoin<OrderAarray11>((t1, ti2) => t1.Id == ti2.fk)
|
||||
.Select((t1, ti2) => new { t1.Id, t1.Name,json= ti2.Json }).ToList();
|
||||
db.CodeFirst.InitTables<Unitaaar2>();
|
||||
db.Insertable(new Unitaaar2() { arr = new string[] { "a", "c" } }).ExecuteCommand();
|
||||
var list141 = db.Queryable<Unitaaar2>()
|
||||
.Select(it => new {
|
||||
x = SqlFunc.JsonIndex(it.arr, 0),
|
||||
x2 = SqlFunc.JsonIndex(it.arr, 1)
|
||||
}).ToList();
|
||||
if (list141.First().x != "a" && list141.Last().x != "c")
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
}
|
||||
public class OrderMain11
|
||||
|
||||
public class Unitaaar2
|
||||
{
|
||||
[SugarColumn(IsJson = true, IsNullable = true)]
|
||||
public string[] arr { get; set; }
|
||||
}
|
||||
public class OrderMain11
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true,IsIdentity =true)]
|
||||
public int Id { get; set; }
|
||||
|
@ -110,8 +110,25 @@ namespace OrmTest
|
||||
var list14=db.Queryable<UnitJsonTestadsga1>().ToList();
|
||||
var list150 = db.Queryable<UnitJsonTest>().ToDictionary(it => it.Id, it => it.Order);
|
||||
var list15 = db.Queryable<UnitJsonTest>().ToDictionaryAsync(it=>it.Id,it=>it.Order).GetAwaiter().GetResult();
|
||||
|
||||
db.CodeFirst.InitTables<Unitaaar2>();
|
||||
db.Insertable(new Unitaaar2() { arr = new string[] { "a", "c" } }).ExecuteCommand();
|
||||
var list141 = db.Queryable<Unitaaar2>()
|
||||
.Select(it => new {
|
||||
x = SqlFunc.JsonIndex(it.arr, 0),
|
||||
x2 = SqlFunc.JsonIndex(it.arr, 1)
|
||||
}).ToList();
|
||||
if (list141.First().x != "a" && list141.Last().x != "c")
|
||||
{
|
||||
throw new Exception("unit error");
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Unitaaar2
|
||||
{
|
||||
[SugarColumn(IsJson = true, IsNullable = true)]
|
||||
public string[] arr { get; set; }
|
||||
}
|
||||
public class UnitJsonTestadsga1
|
||||
{
|
||||
[SqlSugar.SugarColumn(Length =2000,IsJson =true)]
|
||||
|
Loading…
Reference in New Issue
Block a user