none
Does DataAdapter.Fill Method have serialization under the hood? RRS feed

  • Question

  • The Fill method retrieves rows from the data source using the SELECT statement specified by an associated SelectCommand property. The connection object associated with the SELECT statement must be valid, but it does not need to be open. If the connection is closed before Fill is called, it is opened to retrieve data, then closed.

    So it may be a stupid question. My understanding is that if there is a database on the remote server, using DataAdapter.Fill method to fetch the data over the wire and the destination is the memory. My question is there a under the hood serialization for the adapter fill method? Otherwise tons of data transfers over the wire for a huge table?

    Tuesday, March 31, 2015 2:56 PM

Answers

  • No there is not any serialization involved done by .Net.

    Received is one resultset which is processed by the datareader. 

    Maybe you can call the creation of the resultset by SQL server serialization, but in fact it is the same likewise a view.

    (Be aware "resultset" is a SQL Server and Oracle name, not a .Net name)


    Success
    Cor


    • Edited by Cor Ligthert Friday, April 3, 2015 2:33 PM
    • Marked as answer by ardmore Monday, April 13, 2015 5:25 PM
    Friday, April 3, 2015 2:32 PM

All replies

  • Hi ardmore,

    -->Does DataAdapter.Fill Method have serialization under the hood?

    I'm afraid not. If you'd like to decrease the amount of transformation. you could add the "where" condition to your SqlCommand.

    SqlDataAdapter catDA = new SqlDataAdapter("SELECT CategoryID, CategoryName FROM Categories Where CategoryID < 100", Conn); 

    If you have any other concern regarding this issue, please feel free to let me know.

    Best regards,
    Youjun Tang



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, April 1, 2015 3:11 AM
  • I'm not sure Youjun really understood your question.  I believe like you said the transfer data from the database is transferred as XML.  XML is the standard method for transferring serialized data.  The XML isn't directly accessible to the user.  I think Youjun thought you were trying to access the XML directly.

    jdweng

    Wednesday, April 1, 2015 3:26 AM
  • I meant by MSDN.

    Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file.

    My question was that "Does DataAdapter.Fill Method have such a process already"? Hopefully it is clear.

    Wednesday, April 1, 2015 12:19 PM
  • The DataAdapter.Fill method adds or refreshes rows in the DataSet to match those in the data source: https://msdn.microsoft.com/en-us/library/system.data.common.dataadapter.fill%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396.

    This is all that it does, you cannot use it to serialize data yourself if that's what you are asking.

    Of course the data that is retrieved from the remote database is serialized somehow internally, how else would it be transfered from one computer to another?


    Please remember to mark helpful posts as answer to close your threads and then start a new thread if you have a new question.

    Wednesday, April 1, 2015 12:24 PM
  • Under the hood of the DataAdapter is the DataReader. 

    Likewise that is SQL for that simply returning a resultset. 

    You can see this happen by using the SQLProfiler tool but that is not a topic of this forum.

    Be aware that a datatable does contain only item information which comes from the database. The rest is mostly references.

     


    Success
    Cor


    Thursday, April 2, 2015 3:40 PM
  • Cor,

    So does DataReader have somehow internal serialization?

    I can't find it at SqlDataReader.cs source code in C# .NET

    Thursday, April 2, 2015 3:55 PM
  • No there is not any serialization involved done by .Net.

    Received is one resultset which is processed by the datareader. 

    Maybe you can call the creation of the resultset by SQL server serialization, but in fact it is the same likewise a view.

    (Be aware "resultset" is a SQL Server and Oracle name, not a .Net name)


    Success
    Cor


    • Edited by Cor Ligthert Friday, April 3, 2015 2:33 PM
    • Marked as answer by ardmore Monday, April 13, 2015 5:25 PM
    Friday, April 3, 2015 2:32 PM