Skip to content

分库业务表关联基础库数据表联合查询 查询不出来数据 #301

Description

@li61609

hardingCore 版本7.8.1.22
var minTime = new DateTime(2024, 1, 1);
var maxTime = new DateTime(2028, 12, 31);

// 一次性Join查询:订单 + 用户
var query = from order in _dbContext.Orders
.Where(o => o.CreationTime >= minTime && o.CreationTime <= maxTime)
join user in _dbContext.Users
on order.UserId equals user.Id into userGroup
from user in userGroup.DefaultIfEmpty()
select new
{
order.Id,
order.UserId,
userName = user != null ? user.Name : "(未知)",
order.Money,
order.CreationTime
};

var result = await query.ToListAsync();

这Orders是按CreationTime按年分库,Users不分库是基础库,分步查询可以查出数据,合并查询查不出来

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions