Home

How do you get a DataTable from dynamical sql text (not stored proc)

In LINQPad, I can easily get a datable from a stored proc:
DataTable dt = MyStoredProc().Tables[0];

But what I'd like to do is get a DataTable from a sql string:
var sql = "select * from MyTable";

If I use ExecuteQueryDynamic, I get back an IEnumerable; not a DataTable.
var result = ExecuteQueryDynamic(sql, "");

Is there a way to either get back a DataTable or a simply way to convert the IEnumerable to a DataTable?

Sign In or Register to comment.