In C #, I use sql scripts to add data to a list, where T will be a class with fields / properties mapped to sql script.
How can I do this in F #? This part uses the stored procedure in a standard way.
using (conn)
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("dbo.query_here", conn))
{
cmd.CommandText = "dbo.query_here";
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandTimeout = 600;
cmd.Parameters.Add(new SqlParameter("@x1", Convert.ToString(x)));
cmd.Parameters.Add(new SqlParameter("@y1", y));
cmd.Parameters.Add(new SqlParameter("@z1", z));
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
MyListOfClasses.Add(new MyDataClass(reader.GetInt32(reader.GetOrdinal("x"))
reader.GetDouble(reader.GetOrdinal("y")),
reader.GetDouble(reader.GetOrdinal("a")),
reader.GetDouble(reader.GetOrdinal("b"))));
}
reader.Close();
}
conn.Close();
I understand that F # is not so straightforward, perhaps like this, but I need to get this data into F # lists in a similar way. Also would prefer sentences that were not functional in nature and followed a similar pattern with C # code.
In the previous thread, someone suggested using records, but still it did not concern SqlDataReader. It would be preferable to have a list of classes so that I can use getters and setters for each element.
" #". , , #, F # SQL Server.