DocSpace-buildtools/common/ASC.Core.Common/EF/Model/User/DbGroup.cs

129 lines
4.5 KiB
C#
Raw Normal View History

namespace ASC.Core.Common.EF
2019-11-25 09:49:12 +00:00
{
2022-02-15 11:01:23 +00:00
public class DbGroup : BaseEntity, IMapFrom<Group>
2019-11-25 09:49:12 +00:00
{
public int Tenant { get; set; }
public Guid Id { get; set; }
public string Name { get; set; }
2019-12-19 14:06:18 +00:00
public Guid? CategoryId { get; set; }
public Guid? ParentId { get; set; }
2019-11-25 09:49:12 +00:00
public string Sid { get; set; }
public bool Removed { get; set; }
public DateTime LastModified { get; set; }
2019-12-17 13:01:59 +00:00
2020-02-21 12:38:04 +00:00
public override object[] GetKeys()
2019-12-17 13:01:59 +00:00
{
return new object[] { Id };
}
2019-11-25 09:49:12 +00:00
}
2020-08-21 02:34:37 +00:00
public static class DbGroupExtension
{
2020-09-06 22:49:03 +00:00
public static ModelBuilderWrapper AddDbGroup(this ModelBuilderWrapper modelBuilder)
2020-09-02 15:23:39 +00:00
{
2020-09-06 22:49:03 +00:00
modelBuilder
.Add(MySqlAddDbGroup, Provider.MySql)
2021-10-12 10:23:20 +00:00
.Add(PgSqlAddDbGroup, Provider.PostgreSql);
2020-09-02 15:23:39 +00:00
return modelBuilder;
}
private static void MySqlAddDbGroup(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbGroup>(entity =>
{
entity.ToTable("core_group");
entity.HasIndex(e => e.LastModified)
2020-11-17 10:47:17 +00:00
.HasDatabaseName("last_modified");
2020-08-21 02:34:37 +00:00
entity.HasIndex(e => new { e.Tenant, e.ParentId })
2020-11-17 10:47:17 +00:00
.HasDatabaseName("parentid");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Id)
.HasColumnName("id")
.HasColumnType("varchar(38)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.CategoryId)
.HasColumnName("categoryid")
.HasColumnType("varchar(38)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.LastModified)
.HasColumnName("last_modified")
.HasColumnType("timestamp")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
entity.Property(e => e.Name)
.IsRequired()
.HasColumnName("name")
.HasColumnType("varchar(128)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.ParentId)
.HasColumnName("parentid")
.HasColumnType("varchar(38)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Removed).HasColumnName("removed");
entity.Property(e => e.Sid)
.HasColumnName("sid")
.HasColumnType("varchar(512)")
.HasCharSet("utf8")
2021-05-14 12:26:18 +00:00
.UseCollation("utf8_general_ci");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Tenant).HasColumnName("tenant");
});
}
2020-09-02 15:23:39 +00:00
private static void PgSqlAddDbGroup(this ModelBuilder modelBuilder)
2020-08-21 02:34:37 +00:00
{
modelBuilder.Entity<DbGroup>(entity =>
{
2020-10-06 07:06:18 +00:00
entity.ToTable("core_group");
2020-08-21 02:34:37 +00:00
entity.HasIndex(e => e.LastModified)
2020-11-17 10:47:17 +00:00
.HasDatabaseName("last_modified");
2020-08-21 02:34:37 +00:00
entity.HasIndex(e => new { e.Tenant, e.ParentId })
2020-11-17 10:47:17 +00:00
.HasDatabaseName("parentid");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Id)
.HasColumnName("id")
.HasMaxLength(38);
entity.Property(e => e.CategoryId)
.HasColumnName("categoryid")
.HasMaxLength(38)
2020-09-06 22:49:03 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.LastModified)
.HasColumnName("last_modified")
.HasDefaultValueSql("CURRENT_TIMESTAMP");
entity.Property(e => e.Name)
.IsRequired()
.HasColumnName("name")
.HasMaxLength(128);
entity.Property(e => e.ParentId)
.HasColumnName("parentid")
.HasMaxLength(38)
2020-09-06 22:49:03 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Removed).HasColumnName("removed");
entity.Property(e => e.Sid)
.HasColumnName("sid")
.HasMaxLength(512)
2020-09-29 17:09:39 +00:00
.HasDefaultValueSql("NULL");
2020-08-21 02:34:37 +00:00
entity.Property(e => e.Tenant).HasColumnName("tenant");
});
}
}
2019-11-25 09:49:12 +00:00
}