Now I found a way to use this feature with TypeProviders. The type provider is the newly introduced feature in F#, but it has a major drawback: cannot have variable in the type declaration. When I wrote Regex Type Provider, I know why should be like this way and it is not easy to fix it. In the meanwhile, this bothers me a lot. Today at least I find a way to give a little bit more flexibility by using a const.
[ < Literal >
let conStr = "< my con string>
type T = Microsoft.FSharp.Data.TypeProviders.SqlDataConnection ( constr )
let db = T.GetDataContext()
This enable me to use conditional compilation to target different database. At least a little more freedom than before.
No comments:
Post a Comment