var AutoQAEvaluationAnswers = from ea in db.EFCAutoQAEvaluationAnswers
join t in db.Transcripts on ea.TranscriptId equals t.Id
join ef in db.EFCForms on ea.FormId equals ef.Id
join lr in db.LLM_Results
on new { transcriptId = t.Id, useCaseId = Guid.Parse(ef.AutoQAItem), question = ef.AutoQAGenAIQuestion }
equals new { transcriptId = lr.transcriptId, useCaseId = lr.useCaseId, question = lr.question }
where t.Id == TransId
select new
{
ea.Id,
ea.TranscriptId,
ea.FormId,
ea.AutoQAType,
ea.Score,
ea.FormAnswer,
ea.AutoQAColour,
ea.CreateBy,
ea.UpdateBy,
ea.UpdateDate,
lr.question,
lr.comments
};
public class EFCAutoQAEvaluationAnswers
{
public Guid Id { get; set; }
public int TranscriptId { get; set; }
public int FormId { get; set; }
public string? AutoQAType { get; set; }
public double? Score { get; set; }
public string? FormAnswer { get; set; }
public string? AutoQAColour { get; set; }
public string? CreateBy { get; set; }
public string? UpdateBy { get; set; }
public DateTime? UpdateDate { get; set; }
}
public partial class Transcript
{
public int Id { get; set; }
public string? Filename { get; set; }
public string? PlayFile { get; set; }
public string? mediaId { get; set; }
public DateTime? Processtime { get; set; }
public DateTime? CreateTime { get; set; }
public string? DirDate { get; set; }
public string? Vbstatus { get; set; }
public string? JSON { get; set; }
public string? TextPlain { get; set; }
public string? TextSort { get; set; }
public string? Project { get; set; }
public string? Link { get; set; }
public string? Createby { get; set; }
public string? Language { get; set; }
public string? Channels { get; set; }
public string? Vocabs { get; set; }
public bool? Diarization { get; set; }
public int? ProjectId { get; set; }
public int? Duration { get; set; }
public int? WordCount { get; set; }
public string? TextVtt { get; set; }
public bool Active { get; set; }
public int? Cvid { get; set; }
public string? Direction { get; set; }
public string? DgId { get; set; }
public string? AgentName { get; set; }
public int? agentChannel { get; set; }
public string? GroupId { get; set; }
public string? AiAnalysis { get; set; }
public Guid? PlayGuid { get; set; }
public string? Qaform { get; set; }
public virtual ICollection CallBiTagHits { get; } = new List();
public virtual ICollection CallBis { get; } = new List();
public virtual ICollection CallJourneys { get; } = new List();
public virtual ICollection CatRuleMatches { get; } = new List();
public virtual ICollection KpPolicyData { get; } = new List();
public virtual ICollection MedicalTerms { get; } = new List();
public virtual ICollection Nemeyscos { get; } = new List();
public virtual ICollection Nlplisteners { get; } = new List();
public virtual ICollection Nlpresults { get; } = new List();
public virtual ICollection Sascores { get; } = new List();
public virtual ICollection TopicSummaries { get; } = new List();
public virtual ICollection TransJsons { get; } = new List();
public virtual ICollection TransMetadata { get; } = new List();
public virtual ICollection Utterances { get; } = new List();
public virtual ICollection Words { get; } = new List();
}
public class EFCForms
{
public int Id { get; set; }
public Guid TemplateId { get; set; }
public string? Name { get; set; }
public string? FieldType { get; set; }
public string? Description { get; set; }
public int? ParentId { get; set; }
public string? QuestionType { get; set; }
public bool? QuestionRequired { get; set; }
public bool? QuestionNotesRequired { get; set; }
public int? FieldOrder { get; set; }
public string? CreateBy { get; set; }
public string? UpdateBy { get; set; }
public DateTime? UpdateDate { get; set; }
public double? Weighting { get; set; }
public bool? AutomaticFail { get; set; }
public string? AutoQAItem { get; set; }
public string? AutoQAGenAIQuestion { get; set; }
}
public class LLM_Results
{
public Guid Id { get; set; }
public int transcriptId { get; set; }
public Guid useCaseId { get; set; }
public string? question { get; set; }
public string? answer { get; set; }
public DateTime createDate { get; set; }
public string? comments { get; set; }
public string? topic { get; set; }
public Guid? promptId { get; set; }
}
Могу ли я узнать, правильный ли мой запрос linq или нет? Если это правильно, почему я получаю эту ошибку?
Моей основной целью было создать запрос linq, используя приведенный ниже запрос SQL
select
ea.Id,
ea.TranscriptId,
ea.FormId,
ea.AutoQAType,
ea.Score,
ea.FormAnswer,
ea.AutoQAColour,
ea.CreateBy,
ea.UpdateBy,
ea.UpdateDate,
lr.question,
lr.comments
from
EFCAutoQAEvaluationAnswers ea
join
Transcripts t on t.Id = ea.TranscriptId
join
EFCForms ef on ea.FormId = ef.Id
join
LLM_Results lr on t.Id = lr.transcriptId
and TRY_CAST(ef.AutoQAItem as uniqueidentifier) = lr.useCaseId
and lr.question = ef.AutoQAGenAIQuestion
where
t.Id = 3759563
Но когда я создаю запрос linq, я получаю эту ошибку:
Microsoft.Data.SqlClient.SqlError: Неверный синтаксис рядом с ключевым словом "И"
SQL Server: Microsoft SQL Azure (окончательная первоначальная версия) – 12.0.2000.8
Это ошибка, которую я получаю, когда пытаюсь выполнить код. (https://i.sstatic.net/Z2MVQ0mS.png)
Сообщение об ошибке: неправильный синтаксис рядом с ключевым словом «И».
StackTrace: [code] at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at Microsoft.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at Microsoft.Data.SqlClient.SqlDataReader.get_MetaData() at Microsoft.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean isAsync, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest) at Microsoft.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String method) at Microsoft.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at Microsoft.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReader(RelationalCommandParameterObject parameterObject) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.InitializeReader(Enumerator enumerator) at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded) at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.Enumerator.MoveNext() at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items) at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable`1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source) at System.Linq.SystemCore_EnumerableDebugView`1.get_Items() [/code] [code]var AutoQAEvaluationAnswers = from ea in db.EFCAutoQAEvaluationAnswers join t in db.Transcripts on ea.TranscriptId equals t.Id join ef in db.EFCForms on ea.FormId equals ef.Id join lr in db.LLM_Results on new { transcriptId = t.Id, useCaseId = Guid.Parse(ef.AutoQAItem), question = ef.AutoQAGenAIQuestion } equals new { transcriptId = lr.transcriptId, useCaseId = lr.useCaseId, question = lr.question } where t.Id == TransId select new { ea.Id, ea.TranscriptId, ea.FormId, ea.AutoQAType, ea.Score, ea.FormAnswer, ea.AutoQAColour, ea.CreateBy, ea.UpdateBy, ea.UpdateDate, lr.question, lr.comments }; [/code] А вот сущности: [code]public class EFCAutoQAEvaluationAnswers { public Guid Id { get; set; } public int TranscriptId { get; set; } public int FormId { get; set; } public string? AutoQAType { get; set; } public double? Score { get; set; } public string? FormAnswer { get; set; } public string? AutoQAColour { get; set; } public string? CreateBy { get; set; } public string? UpdateBy { get; set; } public DateTime? UpdateDate { get; set; } }
public partial class Transcript { public int Id { get; set; }
public string? Filename { get; set; } public string? PlayFile { get; set; } public string? mediaId { get; set; }
public DateTime? Processtime { get; set; } public DateTime? CreateTime { get; set; }
public string? DirDate { get; set; } public string? Vbstatus { get; set; } public string? JSON { get; set; } public string? TextPlain { get; set; } public string? TextSort { get; set; } public string? Project { get; set; } public string? Link { get; set; } public string? Createby { get; set; } public string? Language { get; set; } public string? Channels { get; set; } public string? Vocabs { get; set; }
public bool? Diarization { get; set; }
public int? ProjectId { get; set; } public int? Duration { get; set; } public int? WordCount { get; set; }
public string? TextVtt { get; set; }
public bool Active { get; set; }
public int? Cvid { get; set; }
public string? Direction { get; set; } public string? DgId { get; set; } public string? AgentName { get; set; }
public int? agentChannel { get; set; }
public string? GroupId { get; set; } public string? AiAnalysis { get; set; }
public Guid? PlayGuid { get; set; }
public string? Qaform { get; set; }
public virtual ICollection CallBiTagHits { get; } = new List();
public virtual ICollection CallBis { get; } = new List();
public virtual ICollection CallJourneys { get; } = new List();
public virtual ICollection CatRuleMatches { get; } = new List();
public virtual ICollection KpPolicyData { get; } = new List();
public virtual ICollection MedicalTerms { get; } = new List();
public virtual ICollection Nemeyscos { get; } = new List();
public virtual ICollection Nlplisteners { get; } = new List();
public virtual ICollection Nlpresults { get; } = new List();
public virtual ICollection Sascores { get; } = new List();
public virtual ICollection TopicSummaries { get; } = new List();
public virtual ICollection TransJsons { get; } = new List();
public virtual ICollection TransMetadata { get; } = new List();
public virtual ICollection Utterances { get; } = new List();
public virtual ICollection Words { get; } = new List(); }
public class EFCForms { public int Id { get; set; } public Guid TemplateId { get; set; } public string? Name { get; set; } public string? FieldType { get; set; } public string? Description { get; set; } public int? ParentId { get; set; } public string? QuestionType { get; set; } public bool? QuestionRequired { get; set; } public bool? QuestionNotesRequired { get; set; } public int? FieldOrder { get; set; } public string? CreateBy { get; set; } public string? UpdateBy { get; set; } public DateTime? UpdateDate { get; set; } public double? Weighting { get; set; } public bool? AutomaticFail { get; set; } public string? AutoQAItem { get; set; } public string? AutoQAGenAIQuestion { get; set; } }
public class LLM_Results { public Guid Id { get; set; } public int transcriptId { get; set; } public Guid useCaseId { get; set; } public string? question { get; set; } public string? answer { get; set; } public DateTime createDate { get; set; } public string? comments { get; set; } public string? topic { get; set; } public Guid? promptId { get; set; } } [/code] Могу ли я узнать, правильный ли мой запрос linq или нет? Если это правильно, почему я получаю эту ошибку? Моей основной целью было создать запрос linq, используя приведенный ниже запрос SQL [code]select ea.Id, ea.TranscriptId, ea.FormId, ea.AutoQAType, ea.Score, ea.FormAnswer, ea.AutoQAColour, ea.CreateBy, ea.UpdateBy, ea.UpdateDate, lr.question, lr.comments from EFCAutoQAEvaluationAnswers ea join Transcripts t on t.Id = ea.TranscriptId join EFCForms ef on ea.FormId = ef.Id join LLM_Results lr on t.Id = lr.transcriptId and TRY_CAST(ef.AutoQAItem as uniqueidentifier) = lr.useCaseId and lr.question = ef.AutoQAGenAIQuestion where t.Id = 3759563 [/code] Но когда я создаю запрос linq, я получаю эту ошибку:
Microsoft.Data.SqlClient.SqlError: Неверный синтаксис рядом с ключевым словом "И"
SQL Server: Microsoft SQL Azure (окончательная первоначальная версия) – 12.0.2000.8