LINQ to SQL(执行自定义SQL表达式):如何用数组值替换参数
方法的使用:LINQ to SQL(执行自定义SQL表达式):如何用数组值替换参数,linq,linq-to-sql,Linq,Linq To Sql,方法的使用: DataContext.ExecuteQuery<TResult>(String, Object[]); 非常感谢您的帮助。因为您使用的是LINQ to SQL,所以可以使用LINQ语法而不是ExecuteQuery,例如: var customers = from c in context.Customers where ids.Contains(c.customer_id) select c; 或者
DataContext.ExecuteQuery<TResult>(String, Object[]);
非常感谢您的帮助。因为您使用的是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)));
context.ExecuteQuery(String.Format(“从客户c中选择c.*,其中c.Customer_id位于({0})”中)”,
Join(“,”,id));
context.ExecuteQuery<SourceTarget>(String.Format("select c.* from Customer c where c.customer_id in ({0})",
String.Join(",", ids)));