Can an SqlDataReader be passed to a session or sent to a client?
For instance, if I retrieved some rows from a database, and want to send this data to another client machine. Can I simply do this by serializing it using json on the server and then deserializing back on the client?
No, only data (no methods or functionality) can be serialized, so the data reader would be useless since you could not call methods to advance the reader, etc. The pattern would be to read all the records into a list of objects from the reader, close it, and then serialize those objects back to the client.
No, any resource-related object cannot be "passed" to a client.
This wouldn't really make sense. You should "materialize" the data reader and pass the results.
I.e. you can create an SqlDataAdapter from your reader, fill a DataTable and pass the DataTable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With