F# working with while loop

Posted by mamu on Stack Overflow See other posts from Stack Overflow or by mamu
Published on 2010-06-05T14:51:48Z Indexed on 2010/06/05 15:12 UTC
Read the original article Hit count: 155

Filed under:

I have a datareader and i want to return collection of rows from it, after reading books for like a day i am not able to find out best way to do it in f#. I can do it normal C# way in F# but that is not why i am using f#

Here is what i am trying to achieve

let values =
    while reader.Read() do
        yield reader.GetString(0), reader.GetInt64(1)

Above is how i am trying to do

  • all values get collected into values, which could be dictinary or tuples or any collection
  • yield can't be used in while loop but that is what i am trying to do

What could be the best way to achieve this

© Stack Overflow or respective owner

Related posts about F#