方法的用法:
DataContext.ExecuteQuery<TResult>(String, Object[]);
以下内容生成InvalidOperationException
消息:
{“无法将节点'Value'格式化为执行SQL。”}
int[] ids = new int[] {1, 2, 3};
context.ExecuteQuery<SourceTarget>(select c.* from Customer c where c.customer_id in {0}, ids);
非常感谢您的帮助。
答案 0 :(得分:1)
由于您使用的是LINQ-to-SQL,因此可以使用LINQ语法而不是ExecuteQuery,例如:
var customers = from c in context.Customers
where ids.Contains(c.customer_id)
select c;
或者,如果您坚持将其作为SQL查询,请尝试:
context.ExecuteQuery<SourceTarget>(String.Format("select c.* from Customer c where c.customer_id in ({0})",
String.Join(",", ids)));