LabelTemplateQueryHelper.cs 1.37 KB
using FoodLabeling.Application.Services.DbModels;
using SqlSugar;

namespace FoodLabeling.Application.Helpers;

/// <summary>
/// 标签模板查询列投影:仅映射库内真实列,避免 ORM 元数据缓存或旧实体仍 SELECT 不存在的 scope 列。
/// </summary>
public static class LabelTemplateQueryHelper
{
    /// <summary>
    /// 列表/详情/引用校验等只读场景:强制 SQL 不含 <c>AppliedPartnerType</c> / <c>AppliedRegionType</c>。
    /// </summary>
    public static ISugarQueryable<FlLabelTemplateDbEntity> ProjectListColumns(
        ISugarQueryable<FlLabelTemplateDbEntity> query) =>
        query.Select(x => new FlLabelTemplateDbEntity
        {
            Id = x.Id,
            IsDeleted = x.IsDeleted,
            CreationTime = x.CreationTime,
            CreatorId = x.CreatorId,
            LastModifierId = x.LastModifierId,
            LastModificationTime = x.LastModificationTime,
            ConcurrencyStamp = x.ConcurrencyStamp,
            TemplateCode = x.TemplateCode,
            TemplateName = x.TemplateName,
            LabelType = x.LabelType,
            Unit = x.Unit,
            Width = x.Width,
            Height = x.Height,
            AppliedLocationType = x.AppliedLocationType,
            ShowRuler = x.ShowRuler,
            ShowGrid = x.ShowGrid,
            VersionNo = x.VersionNo,
            State = x.State
        });
}