DataReaderの結果を解析する関数があり、返されるアイテムの数がわからないので、while..do
ループを使用してリーダーを反復処理したいと思います。結果は特定のタイプのリストになるはずです。
(fun(reader) ->
[
while reader.Read() do
new CityType(Id=(reader.GetInt32 0), Name=(reader.GetString 1), StateName=(reader.GetString 2))
])
これは私が試したものですが、私が受け取る警告は次のとおりです。
This expression should have type 'unit', but has type 'CityType'. Use 'ignore' to discard the result of the expression, or 'let'
to bind the result to a name.
では、DataReaderを反復処理してリストを作成するための最良の方法は何でしょうか。