R – How to convert IEnumerable to xml or dataset

datasetienumerablelinqxml

This is the code:

IEnumerable<table> results = db_dane.ExecuteQuery<table>(query);
  • table – is a database table,
  • query – sql query (example: select * from table),
  • db_dane – linq datacontext.

How to convert results of this query to xml or dataset?

Best Answer

My best thought is to convert it to a List through ToList(), and then looping through that to convert it to a data table.

http://ayende.com/Blog/archive/2007/05/09/Converting-an-object-collection-to-a-DataSet.aspx

Messy, but should work.