0

Hi There

I am new to c#. I am using SqlDataReader to read database records(using c#).I have found lots of way to do it,but for performance i have found that ordinal reading is fast. Now I want to read a guid field ,as we know that with ordinal reading we can do this in two way
1)reader.GetGuid(0)
2) (Guid)reader[0]

but I don't know which will be faster...

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by sknake
0

Test it and find out. The different will be negligible either way so I would concern myself with "which code base is easier to maintain". If you're looking for blazing-fast performance then .NET is not the way to go.

Also using the SqlDataReader like that could be considered slower because from the looks of it you're requesting records one-by-one. Sometimes it is best to ask for all of the data and cache it memory, do your processing, then free the memory. The network layer of retrieving data has a fixed amount of overhead to initiate a request for any amount of records, ie: send command to get data, wait for response.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.