Why is F# member not found when used in subclass
Posted
by James Black
on Stack Overflow
See other posts from Stack Overflow
or by James Black
Published on 2010-05-16T04:51:47Z
Indexed on
2010/05/16
5:00 UTC
Read the original article
Hit count: 282
I have a base type that I want to inherit from, for all my DAO objects, but this member gets the error further down about not being defined:
type BaseDAO() =
member v.ExecNonQuery2(conn)(sqlStr) =
let comm = new MySqlCommand(sqlStr, conn, CommandTimeout = 10)
comm.ExecuteNonQuery |> ignore
comm.Dispose |> ignore
I inherit in this type:
type CreateDatabase() =
inherit BaseDAO()
member private self.createDatabase(conn) =
self.ExecNonQuery2 conn "DROP DATABASE IF EXISTS restaurant"
This is what I see when my script runs in the interactive shell:
--> Referenced 'C:\Program Files\MySQL\MySQL Connector Net 6.2.3\Assemblies\MySql.Data.dll'
[Loading C:\Users\jblack\Documents\Visual Studio 2010\Projects\RestaurantService\RestaurantDAO\BaseDAO.fs]
namespace FSI_0106.RestaurantServiceDAO
type BaseDAO =
class
new : unit -> BaseDAO
member
ExecNonQuery2 : conn:MySql.Data.MySqlClient.MySqlConnection ->
sqlStr:string -> unit
member execNonQuery : sqlStr:string -> unit
member
execQuery : sqlStr:string *
selectFunc:(MySql.Data.MySqlClient.MySqlDataReader ->
'a list) -> 'a list
member f : x:obj -> string
member Conn : MySql.Data.MySqlClient.MySqlConnection
end
[Loading C:\Users\jblack\Documents\Visual Studio 2010\Projects\RestaurantService\RestaurantDAO\CreateDatabase.fs]
C:\Users\jblack\Documents\Visual Studio 2010\Projects\RestaurantService\RestaurantDAO\CreateDatabase.fs(56,14): error FS0039: The field, constructor or member 'ExecNonQuery2' is not defined
I am curious what I am doing wrong.
I have tried not inheriting, and just instantiating the BaseDAO
type in the function, but I get the same error.
I started on this path because I had a property that had the same error, so it seems there may be a problem with how I am defining my BaseDAO
type, but it compiles with no error, which further confuses me about this problem.
© Stack Overflow or respective owner