Comments (14)
Robert,
I think there are 2 ways to approach this problem without changing TP.
- If you have enough control over a database pull big chunks of SQL into reusable FUNCTIONs and VIEWs. You can combine them with APPLY operator. It's great practice.
- Have dedicated F# file that contains sql scripts and type aliases for commands. It's similar to what I have on WebApi example
http://github.com/dmitry-a-morozov/FSharp.Data.SqlCommandTypeProvider/blob/master/WebApi/DataAccess.fs
It will be kinda "Repository" pattern.
from fsharp.data.sqlclient.
- There are cases for and against this, and like you touched upon, you don't always have control over the db. When many apps are hitting a single db, I think it is downright inappropriate. :)
- This is what I would do if I had to. Actually, with external files, in a bigger app, I still would do this, just to keep the type definitions in a single place.
FSharp.Data implements this and it is pretty good. You can have your file as a proper .sql file with all the benefits of that;
- Syntax coloring
- Intellisense
- Error squigglies
- diffs are nicer
Last time I looked in FSharp.Data, it was actually the same parameter. If it looks like a file name and the file exists, read the file, otherwise parse the content. Good enough, but maybe have an optional 'content' param and an optional 'filename' param? If both exist or none exist=compile error.
from fsharp.data.sqlclient.
Good point. We agreed to do it FSharp.Data - style.
from fsharp.data.sqlclient.
If you want to reuse that piece from FSharp.Data, use the parseTextAtDesignTime
function (https://github.com/ovatsus/FSharp.Data/blob/Async/src/Providers/Helpers.fs#L105)
from fsharp.data.sqlclient.
@ovatsus Thanks for suggestion.
from fsharp.data.sqlclient.
@ovatsus The link is broken :( I guess you meant https://github.com/ovatsus/FSharp.Data/blob/master/src/Providers/Helpers.fs#L105
from fsharp.data.sqlclient.
Yes, or https://github.com/fsharp/FSharp.Data/blob/master/src/Providers/Helpers.fs#L105
from fsharp.data.sqlclient.
@rojepp, We didn't forget your request - @dsevastianov will work on this feature.
from fsharp.data.sqlclient.
@dsevastianov Great! I will test it later.
from fsharp.data.sqlclient.
@rojepp My pleasure. This is naive implementation, I decided not to go with full-fledged implementation as in FSharp.Data just yet. We might want to look into some caching later on as well, it's getting a bit slow.
from fsharp.data.sqlclient.
By full-fledged, you mean change notification?
I haven't noticed it being slow yet..
from fsharp.data.sqlclient.
I mean, with support for web URIs, caching, async reads, etc.
from fsharp.data.sqlclient.
Just tried it out, works fine!
I think it is pretty unlikely that someone would put their Sql code on a web page and use that for building their software. :) Also, async is pretty pointless if you immediately have to wait for it to finish, which should be the case here. What I'm missing is change notification. When I edit the sql file and save it, types should immediately update, like in FSharp.Data.
Maybe I should put it in an issue of its own?
from fsharp.data.sqlclient.
Yes, if you could. I'd expect it's going to be tricky.
from fsharp.data.sqlclient.
Related Issues (20)
- Dacpac support info HOT 3
- "F# Formatting" link is broken
- Can't build/run from the commandline, but can from Visual Studio 2019 HOT 2
- Question: Creating a provider without an access to DB HOT 3
- SqlEnumProvider breaks VS 2019 HOT 2
- Not platform detection Fable HOT 1
- Build is broken without full VS installation
- Fixed length binary columns in user defined table types fail when constructed HOT 8
- Cannot use User Defined Table Types with the SqlCommandProvider HOT 5
- .NET 6 support HOT 6
- One line summary of the bug HOT 2
- TVP Column Ordering is incorrect as of version 2.1.0
- Cannot use parameter name more than once in a script HOT 3
- System.Data.SqlClient is not supported on this platform. HOT 5
- Conversion failed when using User Defined Table Types HOT 1
- Any 2023 tricks for running on Windows? HOT 3
- NullReferenceException in SqlConnection.UseLocally HOT 1
- Support for 'Active Directory Interactive' authentication HOT 3
- dotnet SDK projects using FSharp.Core version 7.0.0 breaks at runtime HOT 3
- SQL LIKE operation doesn't recognize variable HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fsharp.data.sqlclient.