schangxiang@126.com
2025-05-21 0e42f871905f207658d822fcbe29aeb57b2156af
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using CMS.Plugin.PipeLineLems.Domain;
using CMS.Plugin.PipeLineLems.Domain.MyTestEntityNames;
using CMS.Plugin.PipeLineLems.Domain.Shared.MyTestEntityNames;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling;
 
namespace CMS.Plugin.PipeLineLems.EntityFrameworkCore.Extensions;
 
/// <summary>
/// EfCore扩展
/// </summary>
public  static partial class CMSPluginEfCoreExtensions
{
    /// <summary>
    /// Includes the details.
    /// </summary>
    /// <param name="queryable">The queryable.</param>
    /// <param name="include">if set to <c>true</c> [include].</param>
    /// <returns></returns>
    public static IQueryable<MyTestEntityName> IncludeDetails(this IQueryable<MyTestEntityName> queryable, bool include = true)
    {
        if (!include)
        {
            return queryable;
        }
 
        return queryable;
    }
 
    /// <summary>
    /// Configures the mytestentityname.
    /// </summary>
    /// <param name="builder">The builder.</param>
    public static void ConfigureMyTestEntityName(this ModelBuilder builder)
    {
        Check.NotNull(builder, nameof(builder));
 
        builder.Entity<MyTestEntityName>(b =>
        {
            //Configure table & schema name
            b.ToTable((CMSPluginDbProperties.DbTablePrefix + "_MyTestEntityNames").ToLower(), CMSPluginDbProperties.DbSchema).HasComment("MyTestEntityName");
 
            b.ConfigureByConvention();
 
            //Properties
            b.Property(x => x.Code).HasMaxLength(MyTestEntityNameConsts.MaxCodeLength).IsRequired().HasComment("编码");
            b.Property(x => x.Name).HasMaxLength(MyTestEntityNameConsts.MaxNameLength).IsRequired().HasComment("名称");
            b.Property(x => x.Sort).HasComment("排序");
            b.Property(x => x.IsDisabled).IsRequired(false).HasComment("是否禁用");
            b.Property(x => x.Remark).HasMaxLength(MyTestEntityNameConsts.MaxRemarkLength).IsRequired(false).HasComment("备注");
 
            b.HasIndex(u => u.Name);
 
            b.ApplyObjectExtensionMappings();
        });
    }
}