#241 adding PoetId to GanjoorCachedRelatedPoem and changing index on the table

This commit is contained in:
Hamid Reza Mohammadi 2021-11-16 19:38:02 +03:30
parent fb284ebaea
commit 739f9f96de
7 changed files with 24 additions and 6 deletions

View File

@ -137,7 +137,7 @@ namespace RMuseum.DbContext
.HasIndex(v => new { v.PoemId, v.CoupletIndex });
builder.Entity<GanjoorCachedRelatedPoem>()
.HasIndex(c => new { c.PoemId, c.RelationOrder });
.HasIndex(c => new { c.PoemId });
//Index set suggested by SQL Server Tuning Wizard -- end

View File

@ -10,7 +10,7 @@ using RMuseum.DbContext;
namespace RMuseum.Migrations
{
[DbContext(typeof(RMuseumDbContext))]
[Migration("20211114151203_GanjoorCachedRelatedPoems")]
[Migration("20211116160621_GanjoorCachedRelatedPoems")]
partial class GanjoorCachedRelatedPoems
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -452,6 +452,9 @@ namespace RMuseum.Migrations
b.Property<int>("PoemId")
.HasColumnType("int");
b.Property<int>("PoetId")
.HasColumnType("int");
b.Property<string>("PoetImageUrl")
.HasColumnType("nvarchar(max)");
@ -466,7 +469,7 @@ namespace RMuseum.Migrations
b.HasKey("Id");
b.HasIndex("PoemId", "RelationOrder");
b.HasIndex("PoemId");
b.ToTable("GanjoorCachedRelatedPoems");
});

View File

@ -13,6 +13,7 @@ namespace RMuseum.Migrations
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PoemId = table.Column<int>(type: "int", nullable: false),
PoetId = table.Column<int>(type: "int", nullable: false),
RelationOrder = table.Column<int>(type: "int", nullable: false),
PoetName = table.Column<string>(type: "nvarchar(max)", nullable: true),
PoetImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
@ -33,9 +34,9 @@ namespace RMuseum.Migrations
});
migrationBuilder.CreateIndex(
name: "IX_GanjoorCachedRelatedPoems_PoemId_RelationOrder",
name: "IX_GanjoorCachedRelatedPoems_PoemId",
table: "GanjoorCachedRelatedPoems",
columns: new[] { "PoemId", "RelationOrder" });
column: "PoemId");
}
protected override void Down(MigrationBuilder migrationBuilder)

View File

@ -450,6 +450,9 @@ namespace RMuseum.Migrations
b.Property<int>("PoemId")
.HasColumnType("int");
b.Property<int>("PoetId")
.HasColumnType("int");
b.Property<string>("PoetImageUrl")
.HasColumnType("nvarchar(max)");
@ -464,7 +467,7 @@ namespace RMuseum.Migrations
b.HasKey("Id");
b.HasIndex("PoemId", "RelationOrder");
b.HasIndex("PoemId");
b.ToTable("GanjoorCachedRelatedPoems");
});

View File

@ -12,6 +12,11 @@
/// </summary>
public int PoemId { get; set; }
/// <summary>
/// poet id
/// </summary>
public int PoetId { get; set; }
/// <summary>
/// poem
/// </summary>

View File

@ -4626,6 +4626,11 @@
poem id
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorCachedRelatedPoem.PoetId">
<summary>
poet id
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.GanjoorCachedRelatedPoem.Poem">
<summary>
poem

View File

@ -76,6 +76,7 @@ namespace RMuseum.Services.Implementation
GanjoorCachedRelatedPoem newRelatedPoem = new GanjoorCachedRelatedPoem()
{
PoemId = poemId,
PoetId = relatedPoem.Cat.PoetId,
RelationOrder = r,
PoetName = relatedPoem.Cat.Poet.Nickname,
PoetImageUrl = $"/api/ganjoor/poet/image{(await context.GanjoorCategories.Where(c => c.ParentId == null && c.PoetId == relatedPoem.Cat.PoetId).AsNoTracking().SingleAsync()).FullUrl}.gif",