public static void AssertEquals(string content, DataTable dt) { StringWriter sw = new StringWriter(); dt.SaveToStream(sw); string actual = sw.ToString(); AssertEquals(content, actual); }
/// <summary> /// Save the data table to the given azure blob. This will overwrite an existing blob. /// </summary> /// <param name="table">instance of table to save</param> /// <param name="container">conatiner</param> /// <param name="blobName">blob name</param> public static void SaveToAzureBlob(this DataTable table, CloudBlobContainer container, string blobName) { var blob = container.GetBlobReference(blobName); using (BlobStream stream = blob.OpenWrite()) using (TextWriter writer = new StreamWriter(stream)) { table.SaveToStream(writer); } }
/// <summary> /// Save the data table to the given azure blob. This will overwrite an existing blob. /// </summary> /// <param name="table">instance of table to save</param> /// <param name="container">conatiner</param> /// <param name="blobName">blob name</param> public static void SaveToAzureBlob(this DataTable table, CloudBlobContainer container, string blobName) { var blob = container.GetBlockBlobReference(blobName); using (var stream = new MemoryStream()) using (TextWriter writer = new StreamWriter(stream)) { table.SaveToStream(writer); writer.Flush(); stream.Seek(0, SeekOrigin.Begin); blob.UploadFromStream(stream); } }
private static string TableToString(DataTable dt) { StringWriter sw = new StringWriter(); dt.SaveToStream(sw); return sw.ToString(); }