我正在使用最新版本的ABP v3_6_1。我创建了两个表作为ObdMaster,并将其推送到DB。
[Table("ObdMaster")]
public class ObdMaster : FullAuditedEntity<int>, IMayHaveTenant, IPassivable, ICreationAudited
{
public const int NumbersLimit = 50;
public const int MaxDescriptionLength = 64 * 1024; //64KB
[Required]
[MaxLength(NumbersLimit)]
public string ObdNumber { get; set; }
[Required]
[MaxLength(NumbersLimit)]
public string SimImeiNumber { get; set; }
[Required]
[MaxLength(NumbersLimit)]
public string SimNumber { get; set; }
[MaxLength(MaxDescriptionLength)]
public string Description { get; set; }
[Required]
public string Type { get; set; }
[Required]
public string Protocol { get; set; }
public int? TenantId { get; set; }
[Required]
public bool IsActive { get; set; }
}
通过迁移可以很好地创建表。 我以
创建了服务 public class ObdMasterAppService : TrackingSystemAppServiceBase, IObdMasterAppService
{
private readonly IRepository<ObdMaster> _obdRepository;
public ObdMasterAppService(IRepository<ObdMaster> repository)
{
_obdRepository = repository;
}
public async Task<ListResultDto<ObdMaster>> GetAll(GetAllObdMasterInput input)
{
var tasks = await _obdRepository
.GetAll()
.WhereIf(!string.IsNullOrEmpty(input.Type), t => t.Type == input.Type)
.WhereIf(!string.IsNullOrEmpty(input.Protocol), t => t.Protocol == input.Protocol)
.OrderByDescending(t => t.CreationTime)
.ToListAsync();
return new ListResultDto<ObdMaster>(
ObjectMapper.Map<List<ObdMaster>>(tasks)
);
}
}
接口:
public interface IObdMasterAppService : IApplicationService
{
Task<ListResultDto<ObdMaster>> GetAll(GetAllObdMasterInput input);
Task<ObdMaster> Create(CreateObdMasterDto input);
}
现在按照SQL事件探查器的GetAll方法,它会针对一个租户触发如下查询:
exec sp_executesql N'SELECT [t].[Id], [t].[CreationTime], [t].[CreatorUserId], [t].[DeleterUserId], [t].[DeletionTime], [t].[Description], [t].[IsActive], [t].[IsDeleted], [t].[LastModificationTime], [t].[LastModifierUserId], [t].[ObdNumber], [t].[Protocol], [t].[SimImeiNumber], [t].[SimNumber], [t].[TenantId], [t].[Type]
FROM [ObdMaster] AS [t]
WHERE (([t].[IsDeleted] = 0) OR ([t].[IsDeleted] <> @__ef_filter__IsSoftDeleteFilterEnabled_0)) AND ([t].[TenantId] IS NULL OR (CASE
WHEN [t].[TenantId] IS NULL
THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
END = @__ef_filter__IsMayHaveTenantFilterEnabled_3))
ORDER BY [t].[CreationTime] DESC',N'@__ef_filter__IsSoftDeleteFilterEnabled_0 bit,@__ef_filter__IsMayHaveTenantFilterEnabled_3 bit',@__ef_filter__IsSoftDeleteFilterEnabled_0=1,@__ef_filter__IsMayHaveTenantFilterEnabled_3=1
下面还有另一个租户:
exec sp_executesql N'SELECT [t].[Id], [t].[CreationTime], [t].[CreatorUserId], [t].[DeleterUserId], [t].[DeletionTime], [t].[Description], [t].[IsActive], [t].[IsDeleted], [t].[LastModificationTime], [t].[LastModifierUserId], [t].[ObdNumber], [t].[Protocol], [t].[SimImeiNumber], [t].[SimNumber], [t].[TenantId], [t].[Type]
FROM [ObdMaster] AS [t]
WHERE (([t].[IsDeleted] = 0) OR ([t].[IsDeleted] <> @__ef_filter__IsSoftDeleteFilterEnabled_0)) AND (([t].[TenantId] = @__ef_filter__CurrentTenantId_1) OR (CASE
WHEN [t].[TenantId] = @__ef_filter__CurrentTenantId_2
THEN CAST(1 AS BIT) ELSE CAST(0 AS BIT)
END = @__ef_filter__IsMayHaveTenantFilterEnabled_3))
ORDER BY [t].[CreationTime] DESC',N'@__ef_filter__IsSoftDeleteFilterEnabled_0 bit,@__ef_filter__CurrentTenantId_1 int,@__ef_filter__CurrentTenantId_2 int,@__ef_filter__IsMayHaveTenantFilterEnabled_3 bit',@__ef_filter__IsSoftDeleteFilterEnabled_0=1,@__ef_filter__CurrentTenantId_1=6,@__ef_filter__CurrentTenantId_2=6,@__ef_filter__IsMayHaveTenantFilterEnabled_3=1
我看到两个租户的表定义等相同。我正在使用相同的存储库。 对于IST查询,我得到了所需的数据,但第二查询却没有。 对我在做什么错有任何想法吗?