문제

var products = db.ExecuteQuery<Product>(
  "SELECT ProductID, ProductName " +
  "FROM Products " +
  "WHERE Discontinued = 0 " +
  "ORDER BY ProductName;"
);

above query works fine but is there any way db.ExecuteQuery<Product> returns DataTable Product

instead of var products?

도움이 되었습니까?

해결책

You shouldn't do this. Why then bothering yourself with LINQ-To-SQL and just use normal ADO methods to get a normal datatable object. This isn't what LINQ-to-SQL is for. You should think in terms of objects.

But, if you need to do this any way: ExecuteQuery returns:a collection of IEnumerable<T>. Then you can convert this list to a datatable. You can use the following function to convert it to a datatable:

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top