Question

Is it possible to limit a sql type provider connection to a few tables? I'm dealing with a huge unsound legacy database. I only want the type provider to analyze a tiny subset of the tables which represent a coherent whole. A subset that I define myself.

Was it helpful?

Solution

The F# type providers for SQL are based on LINQ to SQL and LINQ to Entities. In both cases, you can define the schema in a local file and generate types just for those explicitly listed entities. See:

Both LINQ to SQL and LINQ to Entities give you a way to generate the schema from a live database (so that you do not have to write everything yourself) and you can then remove the tables you do not want to expose. (Although, the caller will still be able to query them using direct SQL query.)

As far as I know (but I may be wrong), the ordinary type providers (like SqlEntityConnection and SqlDataConnection will actually generate classes for all the tables, because they are just lightweight wrappers for standard .NET tools. But other providers, like those in F# Data do not generate any types.)

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