MySqlDataReader example with 2 sets of brackets

32 Views Asked by At

on the internet i saw an MySqlDataReader example.

It was saying something like:

read("products")("amount")

I know you can get data from field "product" from the reader by read("product") but I didn't understand the second () set.
Nowhere info to be found about it.
Is it invalid syntax or a not documented option?

1

There are 1 best solutions below

0
On

The .read method is used to advance the cursor forward. You can look up the spec online here: https://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqldatareader.read%28v=vs.110%29.aspx. I've never seen anything like that syntax myself and certainly the doc doesn't indicate it exists.

If you want to retrieve multiple column values in one go you can use .GetValues(). This will populate an array of objects so depending on what you want to do with the data you may need to cast them after retrieval.