sql - 使用“匿名”表值参数执行存储查询
问题描述
我正在尝试ObjectContext.ExecuteStoreQuery
使用表值 SQL 参数执行
var data = new DataTable();
data.Columns.Add("NAME1", typeof(int));
data.Columns.Add("NAME2", typeof(int));
... add rows to the data table
SqlParameter param = new SqlParameter()
{
ParameterName = "@pairs",
Value = data,
SqlDbType = SqlDbType.Structured
};
ObjectContext.ExecuteStoreQuery<long>(
"select ID" +
"from TEST t join @pairs p " +
"on t.NAME1 = p.NAME1 and t.NAME2= p.NAME2"
)
执行终止并出现以下错误:
System.ArgumentException: '表类型参数'@pairs' 必须具有有效的类型名称。'
我知道我没有指定类型名称,因为这不是数据库中现有的表类型。那么,有没有办法将任何非原始参数的列表传递给查询?还是我错过了什么?
任何使用ObjectSet/Queryable
代替本机查询的替代解决方案都将被接受。
解决方案
推荐阅读
- nstextfield - 如何从 control:textView:doCommandBySelector 获取 nstextfield
- python - python相当于SAS中的过程FACTMAC
- r - 如何根据另一列中值的出现设置因子水平顺序?
- python - 使用 Python 抓取 XML 文件
- python - 类似于 numpy.take 的函数,用于索引 out 参数
- api - 如何使用 gRPC 创建一个 rest API 来读取 go lang 中的文本或任何文件?
- jquery - 我的 jquery 正在工作,直到仅在 sharepoint 中刷新
- amazon-web-services - 如何在 AppDrag 上导出我的项目?
- python - 如何使用 ruamel.yaml 转储文字标量
- mkdocs - 如何链接pdf