Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are Type providers always read-only?

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?

like image 411
user2809397 Avatar asked Sep 24 '13 03:09

user2809397


1 Answers

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.

like image 146
Tomas Petricek Avatar answered Oct 14 '22 11:10

Tomas Petricek