SQL query fails in EF Core

吃可爱长大的小学妹 提交于 2020-04-17 20:23:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!