type-providers

Type provider and big XML file

百般思念 提交于 2020-01-06 20:13:14
问题 I am wondering what are the good practices in using type provider in F#, I have an XML file (25Mo+), I thought it will not be an issue but my Visual Studio is suffering a lot loll. What is usually the good practice, to define a complete template of the XML with the minimum of data and Load the content later ? And if we load a big file with optional node, the type will be inferred by the most complete one ? Thanks 回答1: The XmlProvider type provider is based on XDocument (LINQ to XML), so it

Should one wrap type providers containing values that have side effects inside a class?

廉价感情. 提交于 2020-01-05 02:32:25
问题 I am trying to implement in my code the excellent advice in the F# coding conventions page https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/conventions. The section Use classes to contain values that have side effects is particularly interesting. It says There are many times when initializing a value can have side effects, such as instantiating a context to a database or other remote resource. It is tempting to initialize such things in a module and use it in subsequent functions.

Why do I get a missing method exception runtime when creating a SqlClient type?

谁说胖子不能爱 提交于 2020-01-03 17:04:34
问题 I have the following code: open FSharp.Data [<Literal>] let connectionString = @"Data Source=(local)\SQLExpress;Integrated Security=SSPI;Database=SfagStage" type InsertEnhet = SqlCommandProvider<"Sql\InsertEnhet.sql", connectionString> let insertEnhet (enhet:Enhet) = let cmd = new InsertEnhet() // <<--- This generates an error runtime cmd.Execute(enhet.Navn, enhet.Enhetsnummer, enhet.LEIKode, enhet.Kommune, DateTime.Now) The row where I create the command is what causing the missing method I

How to approach writing an F# type provider that enforces complex schema?

守給你的承諾、 提交于 2020-01-03 10:17:09
问题 Just recently I worked with some data for traffic and travel information, that is data in Datex2 format. The project wasn't long and is over now, and I went on as usually and generated a bunch of strongly typed C# classes with xsd.exe tool, did some serializing, light processing and so forth. However, now in hindsight I became to wonder if this would have been a good case for an F# type provider and so to take my first stab on this subject. With this in mind, how should one approach a

Using F# JsonProvider within a portable class library fails

风格不统一 提交于 2020-01-02 07:30:56
问题 I'm trying to use the JsonProvider and I'm getting the following error when I call a function on it: System.TypeInitializationException was unhandled Message: An unhandled exception of type 'System.TypeInitializationException' occurred in PortableLibrary1.dll Additional information: The type initializer for '<StartupCode$PortableLibrary1>.$PortableLibrary1' threw an exception. I have a basic console application as follows: module Pinit = open FSharp.Data type JsonT = JsonProvider<"""..\myFile

F# Type Providers very very slow build

六月ゝ 毕业季﹏ 提交于 2020-01-01 03:18:05
问题 I'm playing around with Type Providers, specifically the sql entity framework type provider. I'm writing tests against a database that has a LOT of objects, and it's remote so the connection is a little slow. every time i build the project it takes a lot of time, good several minutes for the build to complete. what am I missing why does the compiler doesn't cache the type information? P.S. It's even worse with F# interactive.... 回答1: Try using the LocalSchemaFile attribute for the data

Weird None behaviour in type providers

喜欢而已 提交于 2019-12-31 01:52:26
问题 have a type provider with three properties 'a', 'b', and 'c' of type 'string', 'string option' and 'int option', respectively. When I have an instance with "", None, and Some 1 in those properties, this fails: (row1.a, row1.b, row1.c) |> should equal ("", None, Some 1) But all of these work fine: row1.a |> should equal "" row1.b |> should equal None row1.c |> should equal (Some 1) ("", None, Some 1) |> should equal ("", None, Some 1) How is this possible? What can make the None in b be

F# type provider - “only return generated types”

安稳与你 提交于 2019-12-30 02:00:12
问题 Trying to encode type-level peano numbers using a type provider: namespace TypeProviderPlayground open System open Microsoft.FSharp.Core.CompilerServices open System.Runtime.CompilerServices [<assembly: TypeProviderAssembly()>] do() type Z = class end type 'a S = class end type N = class end [<TypeProvider>] type PeanoProvider(s: TypeProviderConfig) = let invalidate = Event<_,_>() interface ITypeProvider with member x.ApplyStaticArguments(typeWithoutArguments, typeNameWithArguments,

F# WsdlService type provider proxy

我与影子孤独终老i 提交于 2019-12-24 05:59:20
问题 I am following the MSDN tutorial for the WsdlService type provider found here. When I run it at home, it works as expected. When I write the same code at work, I am getting a design time exception: The type provider 'Microsoft.FSharp.Data.TypeProviders.DesignTime.DataProviders' reported an error: Error: Cannot obtain Metadata from http://msrmaps.com/TerraService2.asmx?WSDL Work does use a proxy and I have to alter the web.config to use a default proxy when consuming WSDL from a C# project in

Preserving Field names across the F#/C# boundary

久未见 提交于 2019-12-23 15:28:37
问题 As a learning exercise, I am doing some data analysis on a 5000-line csv file using F# and F#'s type-provider functionality. When I use the type-provider-generated type in f#, naturally the header rows of the csv file become the field names of the type. type restaurantCsv = CsvProvider<"C:\Users\Paul\Desktop\HealthDepartment\RestaurantRatings2013.csv",HasHeaders=true> type RawInspectionData(filename : string) = member this.allData = restaurantCsv.Load(filename) member public this