.net Core 2.2 不支持Saop返回类型为 DataTable ,DataSet list等.
只好通过 DataTable的 WriteXML/ReadXML 来实现对于DataTable 的传输
服务端
public Stream ExecuteDs(string _Tsql) { var conn = "Data Source=(LocalDB)\MSSQLLocalDB; Database=abpzero71;MultipleActiveResultSets=true;"; using (var sqlConnection = new SqlConnection(conn)) { DataTable table = new DataTable("MyTable"); var dataTables = sqlConnection.ExecuteReader(_Tsql); table.Load(dataTables); System.IO.MemoryStream xmlStream = new System.IO.MemoryStream(); table.WriteXml(xmlStream, XmlWriteMode.WriteSchema); xmlStream.Position = 0; return xmlStream; }
}
//客户端
var result2 = client.ExecuteDsAsync("select 1 a ").Result; MemoryStream mem = new MemoryStream(result2); DataTable newTable = new DataTable(); newTable.ReadXml(mem); Console.WriteLine(JsonConvert.SerializeObject(newTable));