Dapper where 子句 IN 数组,不存在从对象类型 System.Collections.Generic.List`1 到已知托管提供程序本机类型的映射

Dapper where clause IN array, No mapping exists from object type System.Collections.Generic.List`1 to a known managed provider native type

我想我正在遵循 this post 的解决方案 但我不确定为什么我得到这个 error:No 存在从对象类型 System.Collections.Generic.List`1 到已知托管提供程序本机类型

的映射

这是我的代码:

public virtual IEnumerable<MyModel> QueryAllById(ICollection<string> ids)
{
    var sql = mySelectQuery + @"
                    WHERE SomeId IN @Ids                            
            ";            
    return Db.Query<MyModel>(sql, new { Ids = new[] { ids } });
}

您可以将 ICollection 转换为数组。

public virtual IEnumerable<MyModel> QueryAllById(ICollection<string> ids)
{
    var sql = mySelectQuery + @"
                    WHERE SomeId IN @Ids                            
            ";            
    return Db.Query<MyModel>(sql, new { Ids = ids.ToArray() });
}