//方式1:
var dd = _repository._Db.Queryable<ConfigAggregateRoot, UserRoleEntity>((o, p) => o.Id == p.Id).Select((o, p) => new
{
o.Id,
o.Remark,
p.RoleId,
});
//方式2:不推荐使用,建议优先使用 Lambda 表达式,因为它更符合 SqlSugar 的设计理念
//如果坚持使用 LINQ 查询语法,要避免提前将查询结果转换为列表,以保持查询的延迟执行特性。
var query = from cust in _repository._Db.Queryable<ConfigAggregateRoot>().ToList()
join d in _repository._Db.Queryable<UserRoleEntity>().ToList() on cust.Id equals d.Id
where cust.Remark == "London"
select cust;
–导航到Module下面, 使用 yi-abp new MES -t module -csf 然后不要表离开此目录,直接使用
yi-abp add-module mes

/// <summary>
/// 主键
/// </summary>
[SugarColumn(IsPrimaryKey = true)]
public override Guid Id { get; protected set; }
[SugarColumn(ColumnName = "Id", ColumnDataType = "INT")]
[SugarColumn(ColumnName = "Id")]
public int Id { get; set; }
[SugarColumn(ColumnName = "Name", ColumnDataType = "NVARCHAR(50)")]
public string? Name { get; set; }
[SugarColumn(ColumnName = "Price", ColumnDataType = "DECIMAL(10, 2)")]
public decimal Price { get; set; }
[SugarColumn(ColumnName = "CreateDate", ColumnDataType = "DATETIME")]
[SugarColumn(ColumnName = "CreateDate")]
public DateTime CreateDate { get; set; }
public Guid? CreatorId { get; set; }
–两个list转换orm,和多表数据之间查询
output = ObjectMapper.Map<List<MenuDto>, List<MenuAggregateRoot>>(menus.Where(x=>x.MenuSource==MenuSourceEnum.Ruoyi).ToList()).Vue3RuoYiRouterBuild();
var result = await db.Queryable<User>()
.LeftJoin<Order>((u, o) => u.Id == o.UserId)
.LeftJoin<Product>((u, o, p) => o.ProductId == p.Id)
.LeftJoin<Category>((u, o, p, c) => p.CategoryId == c.Id)
.Select((u, o, p, c) => new UserOrderProductCategoryDto
{
UserName = u.Name,
ProductName = p != null ? p.ProductName : null,
CategoryName = c != null ? c.CategoryName : null
})
.ToListAsync();
2150

被折叠的 条评论
为什么被折叠?



