Blame view

美国版/Food Labeling Management Code/Yi.Abp.Net8/module/food-labeling-us/FoodLabeling.Application/Helpers/LabelQueryHelper.cs 1.44 KB
87280ae7   李曜臣   2026-0707
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  using FoodLabeling.Application.Services.DbModels;
  using SqlSugar;
  
  namespace FoodLabeling.Application.Helpers;
  
  /// <summary>
  /// 标签查询列投影:不含 <c>AppliedRegionType</c>(未迁移时由 <see cref="LabelRegionSchemaHelper"/> 读写)。
  /// </summary>
  public static class LabelQueryHelper
  {
      /// <summary>只读查询入口:强制列投影。</summary>
      public static ISugarQueryable<FlLabelDbEntity> QueryProjected(ISqlSugarClient db) =>
          ProjectListColumns(db.Queryable<FlLabelDbEntity>());
  
      /// <summary>列表/详情/引用校验等只读场景:SQL 不含 <c>AppliedRegionType</c></summary>
      public static ISugarQueryable<FlLabelDbEntity> ProjectListColumns(
          ISugarQueryable<FlLabelDbEntity> query) =>
          query.Select(x => new FlLabelDbEntity
          {
              Id = x.Id,
              IsDeleted = x.IsDeleted,
              CreationTime = x.CreationTime,
              CreatorId = x.CreatorId,
              LastModifierId = x.LastModifierId,
              LastModificationTime = x.LastModificationTime,
              ConcurrencyStamp = x.ConcurrencyStamp,
              LabelCode = x.LabelCode,
              LabelName = x.LabelName,
              TemplateId = x.TemplateId,
              LocationId = x.LocationId,
              LabelCategoryId = x.LabelCategoryId,
              LabelTypeId = x.LabelTypeId,
              LabelType = x.LabelType,
              State = x.State,
              LabelInfoJson = x.LabelInfoJson
          });
  }