在上一篇文章的回复之后,我正试图将我的代码从sql语句转换为Linq,但是当我尝试执行它时遇到了以下异常。
这段代码有效
DateTime SentDate = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss"), "yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture);
现在我试图做
return (await conn.QueryToListAsync<Condizione>(
@"SELECT A.*, Y.DESCRIZIONE AS MACRORAMOSTR,X.PROGR_CATEGORIA
FROM VW_CONDIZIONI A
INNER JOIN CONDIZIONI_CATEGORIE X ON X.ID_CONDIZIONE = A.ID_CONDIZIONE
INNER JOIN BGRUPPO_RAMO Y ON Y.ID = X.ID_GRUPPO_RAMO WHERE A.ID_CONDIZIONE = @ID_CONDIZIONE",
new {ID_CONDIZIONE = id})).First();
我得到了这个例外
var eee = await conn.VwCondizioni.Where(x => x.IdCondizione == id).Join(
conn.CondizioniCategorie, x => x.IdCondizione, y => y.IdCondizione, (a, b) =>
new { a.IdCondizione, b.ProgrCategoria, b.IdGruppoRamo, a.DataDecorrenza, b.IdCategoria })
.Join(conn.GruppoRamo, x => x.IdGruppoRamo, y => y.Id, (a, b) =>
new Condizione
{
MacroRamoStr = b.Descrizione,
ProgessivoCategoria = a.ProgrCategoria,
DataDecorrenza = a.DataDecorrenza,
Id = a.IdCondizione,
IdCategoria = a.IdCategoria.Value
}).FirstAsync();
return eee;
我在做什么错? 谢谢