My application uses DataRows and th开发者_如何转开发ey are not serializable. Is there a workaround for the same?
Put them into a data table and that into a dataset. That should serialize correctly.
You could try to create a List<object>
.
Then fill the List scanning DataRows
, and serialize List.
DataTable dt = dataRow.Table.Clone();
dt.ImportRow(dataRow);
dt.AcceptChanges();
string xml = string.Empty;
using (var writer = new StringWriter())
{
dt.WriteXml(writer);
xml = writer.ToString();
}
精彩评论