gpt4 book ai didi

c# - Entity Framework - 带有参数列表 <> 的 SqlQuery

转载 作者:行者123 更新时间:2023-11-30 17:46:40 25 4
gpt4 key购买 nike

<分区>

我正在尝试使用 EF 通过 IN 子句查询数据库:

List<int> ids = new List<int> {1,2,3,4....20};
string sql = GetSql(ids);
//sql is "SELECT * FROM Student WHERE Id in (@p0, @p1, @p2 ... @p19)"
var res = db.Set<Student>().SqlQuery(sql, ids);

但是我得到以下异常:

不存在从对象类型 System.Collections.Generic.List`1[[System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]] 到已知托管提供程序 native 的映射类型。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com