问题
I have a method in the repository (EF Core) that should produce a complex request to the database:
public Task<List<Invoice>> GetOrderedVInvoicesAsync(string email, string lang, int rows, int offset)
{
return _contex.VInvoice.FromSqlInterpolated($"SELECT DocumentNumber,DocumentDate,DocumentReference,SerialNumber,ProductCode,Description,Certificate FROM vInvoice WHERE CHECKSUM(DocumentNumber + DocumentReference + CAST(DocumentDate AS VARCHAR)) IN (SELECT CHECKSUM(DocumentNumber + DocumentReference + CAST(DocumentDate AS VARCHAR)) FROM vInvoice WHERE Email={email} AND Language={lang} GROUP BY DocumentNumber,DocumentDate,DocumentReference ORDER BY DocumentDate OFFSET {offset} ROWS FETCH NEXT {rows} ROWS ONLY)").ToListAsync();
}
But he gives me an error
The required column 'Email' was not present in the results of a 'FromSql' operation.
Tell me where I was wrong
来源:https://stackoverflow.com/questions/60101749/sql-query-fails-in-ef-core