Question

I have looked through a number of Type Provider samples and videos and have always seen them to be read-only. My questions: Are Type providers always read-only or can they also provide write access? Is there an example for providing/using write access?

Was it helpful?

Solution

As mentioned by John, the standard SQL type provider allows you to create new entities and store them in the database and there are no theoretical reasons why this would not be possible (you can emit mutable properties).

The F# Data type providers are generally read only, but an older version of the document (JSON, XML, ...) used to emit mutable properties, so you could modify JSON and XML files. You can have a look at the samples in tests here. The same branch also includes source code for the provider implementation (if you wanted to have a look at that).

I think that the problem with write API is that it is quite difficult to design. For some of the discussions about this, see this discussion and the FSharpX issues linked from there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top