using System.Data; using Dapper; using PlotLine.Models; using PlotLine.Services; namespace PlotLine.Data; public interface INameManuscriptRepository { Task Scope(int user,int project); Task Search(int user,int project,string name); } public sealed class NameManuscriptRepository(ISqlConnectionFactory factory):INameManuscriptRepository { public async Task Scope(int user,int project){using var db=factory.CreateConnection();return await db.QuerySingleAsync("dbo.NameManuscript_Search",new{UserID=user,ProjectID=project},commandType:CommandType.StoredProcedure);} public async Task Search(int user,int project,string name) { using var db=factory.CreateConnection();using var rows=await db.QueryMultipleAsync("dbo.NameManuscript_Search",new{UserID=user,ProjectID=project,Name=NameTextMatcher.Prefilter(name),Take=NameTextMatcher.MaximumParagraphs},commandType:CommandType.StoredProcedure); var scope=await rows.ReadSingleAsync();var paragraphs=(await rows.ReadAsync()).ToList();return NameTextMatcher.Match(name,scope,paragraphs); } }