Ado.net (4.5): How to efficiently determine empty result set using async API’s

Answered Ado.net (4.5): How to efficiently determine empty result set using async API’s

  • Monday, December 03, 2012 5:58 PM
     
     

    I’m confused a bit on how to tell if a reader has rows (the docs don’t it make any clearer…)

    Single empty result set:

    var rc = await reader.ReadAsync();

    I assume rc == true means I have rows so it’s not necessary to check reader.HasRows again.

    But what about multiple result sets?

    var rc = await reader.NextResultAsync();
    Does rc == true mean I have rows?
    What’s the return value semantics?
    Do I need to test the next call to reader.ReadAsync() again? or should I check reader.HasRows before advancing the reader?

    So basically, what’s the best practice to exit early?

    10x


    itai

    • Moved by Iric Wen Wednesday, December 05, 2012 9:02 AM (From:SQL Server Data Access)
    •  

All Replies