简体   繁体   English

SQL Server返回C#的内容是什么

[英]What does SQL Server return to C#

We can easily work with SQL Server databases with the help of System.Data.SqlClient library in C#. 我们可以在C#中的System.Data.SqlClient库的帮助下轻松使用SQL Server数据库。

We can return values from stored procedures or we can write sql commands by hardcoding them in C# code. 我们可以从存储过程返回值,或者我们可以通过在C#代码中对它们进行硬编码来编写sql命令。

Then we pass the result to a SqlDataReader to read the values. 然后我们将结果传递给SqlDataReader来读取值。

But I am really wondering what SQL Server returns to C#. 但我真的很想知道SQL Server返回C#。

C# makes the call to SQL Server and SQL Server gives something (XML, JSON or whatever it is) to C# on return. C#调用SQL Server,SQL Server在返回时给C#提供了一些东西(XML,JSON或其他任何东西)。

What is this thing really? 这件事真的是什么? And how can we get only this thing if we want to read it through manually ourselves? 如果我们想通过手动阅读它,我们怎么才能得到这个东西呢?

I believe SQL Server at least used to use TDS for its data transfer. 我相信SQL Server至少习惯使用TDS进行数据传输。 I don't know whether it still does - and using it directly would make your code very brittle in the face of changes within SQL Server. 我不知道它是否仍然存在 - 并且直接使用它会使您的代码在SQL Server中发生变化时非常脆弱。 The whole point of having client libraries is to isolate you from the intricacies of the protocol. 拥有客户端库的重点是将您与协议的复杂性隔离开来。

What benefit are you trying to derive from reading through this manually, over (say) using SqlDataReader , which is about as low-level as most applications will ever need? 您尝试通过手动读取(比如说)使用SqlDataReader来获得什么好处 ,这与大多数应用程序所需的一样低?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM