mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-20 00:44:19 +08:00
Add user test case
This commit is contained in:
parent
1b952892f0
commit
37d5f7c6b2
@ -34,6 +34,7 @@ namespace OrmTest
|
||||
}
|
||||
public static void Init()
|
||||
{
|
||||
Unitsdfayderqys.Init();
|
||||
Unitsdfaysrs.Init();
|
||||
Unitdslasdgy.Init();
|
||||
Unitdafaaaaa.Init();
|
||||
|
@ -50,6 +50,15 @@ namespace Demo
|
||||
File = s.Image,
|
||||
//Image = s.Image == null ? null : new UploadFile() { Id = s.FileId, Url = s.Image == null ? "" : s.Image.FilePath }
|
||||
}).ToPageList(1, 2, ref total);
|
||||
|
||||
var isTrue = true;
|
||||
var list2 = Db.Queryable<SpShangPin>()
|
||||
.Select(s => new ShangPinView()
|
||||
{
|
||||
Id = s.Id,
|
||||
Image = new UploadFile() { Id = s.FileId, Url = isTrue?s.Id.ToString():s.Name},
|
||||
|
||||
}).ToList();
|
||||
return total;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
using NetTaste;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
internal class Unitsdfayderqys
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
var db = NewUnitTest.Db;
|
||||
db.CodeFirst.InitTables<WarehoseReqDetailEntity, SysItemsEntity>();
|
||||
db.DbMaintenance.TruncateTable<WarehoseReqDetailEntity, SysItemsEntity>();
|
||||
db.Insertable(new WarehoseReqDetailEntity()
|
||||
{
|
||||
agrname = "测试农资",
|
||||
agrtype = "1",
|
||||
agrclass = "化肥",
|
||||
factory = "测试工厂",
|
||||
intnum = 100,
|
||||
warehosereqno = "REQ001",
|
||||
strno = ""
|
||||
}).ExecuteReturnEntity();
|
||||
|
||||
db.Insertable(new SysItemsEntity()
|
||||
{
|
||||
fid = "1",
|
||||
fencode = "ITEM001",
|
||||
fparentid = "1",
|
||||
ffullname = "",
|
||||
fistree = true,
|
||||
flayers = 1
|
||||
// 其他需要的测试字段
|
||||
}).ExecuteReturnEntity();
|
||||
|
||||
|
||||
var list = db.Queryable<WarehoseReqDetailEntity>().Includes(x => x.SysItems)
|
||||
// .GroupBy(x => new { x.agrname, x.agrtype, x.agrclass, x.factory })
|
||||
.Select(x => new { x.factory, x.SysItems })
|
||||
.ToList();
|
||||
|
||||
}
|
||||
[SugarTable("WarehoseReqDetail")]
|
||||
public class WarehoseReqDetailEntity
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string strno { get; set; }
|
||||
public string agrname { get; set; }
|
||||
public string agrtype { get; set; }
|
||||
public string factory { get; set; }
|
||||
public string agrclass { get; set; }
|
||||
public Int32 intnum { get; set; }
|
||||
public string warehosereqno { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(agrtype), nameof(SysItemsEntity.fid))]
|
||||
public SysItemsEntity SysItems { get; set; }
|
||||
|
||||
}
|
||||
[SugarTable("SysItems")]
|
||||
public class SysItemsEntity
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string fid { get; set; }
|
||||
public string fparentid { get; set; }
|
||||
public string fencode { get; set; }
|
||||
public string ffullname { get; set; }
|
||||
public Boolean fistree { get; set; }
|
||||
public Int32 flayers { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(fparentid), nameof(SysItemsEntity.fid))]
|
||||
public SysItemsEntity Parent { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user