index for GanjoorPostId in narrations

This commit is contained in:
Hamid Reza Mohammadi 2020-10-25 13:27:39 +03:30
parent bf4e36cacc
commit c8a55d6a82
7 changed files with 1591 additions and 6 deletions

View File

@ -71,6 +71,9 @@ namespace RMuseum.DbContext
builder.Entity<RTagValue>()
.HasIndex(t => t.FriendlyUrl);
builder.Entity<PoemNarration>()
.HasIndex(p => p.GanjoorPostId);
builder.Entity<GanjoorCat>()
.HasIndex(c => c.FullUrl);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace RMuseum.Migrations
{
public partial class GanjoorPostIdIndex : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_AudioFiles_GanjoorPostId",
table: "AudioFiles",
column: "GanjoorPostId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_AudioFiles_GanjoorPostId",
table: "AudioFiles");
}
}
}

View File

@ -340,7 +340,7 @@ namespace RMuseum.Migrations
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<string>("FullUrl")
.HasColumnType("nvarchar(450)");
@ -371,7 +371,7 @@ namespace RMuseum.Migrations
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<int>("CatId")
.HasColumnType("int");
@ -515,6 +515,8 @@ namespace RMuseum.Migrations
b.HasKey("Id");
b.HasIndex("GanjoorPostId");
b.HasIndex("OwnerId");
b.HasIndex("ReviewerId");

View File

@ -14,6 +14,7 @@ namespace RMuseum.Models.GanjoorAudio.ViewModels
/// constructor
/// </summary>
/// <param name="src"></param>
/// <param name="poem"></param>
public PoemNarrationViewModel(PoemNarration src, GanjoorPoem poem)
{
Id = src.Id;

View File

@ -2051,6 +2051,7 @@
constructor
</summary>
<param name="src"></param>
<param name="poem"></param>
</member>
<member name="P:RMuseum.Models.GanjoorAudio.ViewModels.PoemNarrationViewModel.Id">
<summary>

View File

@ -39,7 +39,7 @@ namespace RMuseum.Services.Implementation
try
{
var source =
from audio in _context.AudioFiles
_context.AudioFiles
.Include(a => a.Owner)
.Where(a =>
(filteredUserId == Guid.Empty || a.OwnerId == filteredUserId)
@ -47,9 +47,12 @@ namespace RMuseum.Services.Implementation
(status == AudioReviewStatus.All || a.ReviewStatus == status)
)
.OrderByDescending(a => a.UploadDate)
join poem in _context.GanjoorPoems
on audio.GanjoorPostId equals poem.Id
select new PoemNarrationViewModel(audio, poem);
.Join(
_context.GanjoorPoems,
audio => audio.GanjoorPostId,
poem => poem.Id,
(audio, poem) => new PoemNarrationViewModel(audio, poem)
);