using CMS.Plugin.HIAWms.Domain;
|
using CMS.Plugin.HIAWms.Domain.Samples;
|
using CMS.Plugin.HIAWms.Domain.Shared.Samples;
|
using Microsoft.EntityFrameworkCore;
|
using Volo.Abp;
|
using Volo.Abp.EntityFrameworkCore.Modeling;
|
|
namespace CMS.Plugin.HIAWms.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<Sample> IncludeDetails(this IQueryable<Sample> queryable, bool include = true)
|
{
|
if (!include)
|
{
|
return queryable;
|
}
|
|
return queryable;
|
}
|
|
/// <summary>
|
/// Configures the sample.
|
/// </summary>
|
/// <param name="builder">The builder.</param>
|
public static void ConfigureSample(this ModelBuilder builder)
|
{
|
Check.NotNull(builder, nameof(builder));
|
|
builder.Entity<Sample>(b =>
|
{
|
//Configure table & schema name
|
b.ToTable((CMSPluginDbProperties.DbTablePrefix + "_Samples").ToLower(), CMSPluginDbProperties.DbSchema).HasComment("Sample");
|
|
b.ConfigureByConvention();
|
|
//Properties
|
b.Property(x => x.Code).HasMaxLength(SampleConsts.MaxCodeLength).IsRequired().HasComment("编码");
|
b.Property(x => x.Name).HasMaxLength(SampleConsts.MaxNameLength).IsRequired().HasComment("名称");
|
b.Property(x => x.Sort).HasComment("排序");
|
b.Property(x => x.IsDisabled).IsRequired(false).HasComment("是否禁用");
|
b.Property(x => x.Remark).HasMaxLength(SampleConsts.MaxRemarkLength).IsRequired(false).HasComment("备注");
|
|
b.HasIndex(u => u.Name);
|
|
b.ApplyObjectExtensionMappings();
|
});
|
}
|
}
|