fsprojects / SQLProvider

A general F# SQL database erasing type provider, supporting LINQ queries, schema exploration, individuals, CRUD operations and much more besides.
https://fsprojects.github.io/SQLProvider
Other
564 stars 144 forks source link

Created entry not available unless I restart the application? #737

Closed arnesahlberg closed 2 years ago

arnesahlberg commented 2 years ago

Description

I’m using SQLProvider to communicate with an MSSQL Server in an application written in F#. I do have a problem, though.

When I run the application I can use the DataContext to add new entries to the Database and submit them. This works and I can see the entries in the SQL server. However, if I then use the same F# application to browse the entries in the database, I do not find them in the DataContext, unless I restart the application.

There must be some way to update the DataContext to see all entries without restarting the application, but I haven’t been able to figure out how this is done. Any tips?

Repro steps

  1. Open a connection to an SQL Server with the SQLProvider
  2. Get the DataContext
  3. Create new entries in one or more tables in the database (by calling let row = ctx.Dbo.TableName.Create() and adding entries to each column by calling row.columnName <- "value").
  4. Submit updates by calling ctx.SubmitUpdates()
  5. Query the database with a query command and I cannot see the added entry (outside the F# application I can see them in the SQL server, so they are there)
  6. Restart the application and the new entry is there.

Expected behaviour

I'd expect the updates to be available in the DataContext when they are submitted.

Actual behaviour

I cannot find them until I restart the program

Related information

Thorium commented 2 years ago

That sounds weird. 1) how about if you create them with a long .``Create(col1, ...)``("test") ? 2) could this be that your transactions block the visibility somehow?

Thorium commented 2 years ago

You can monitor the query creation like this: http://fsprojects.github.io/SQLProvider/core/querying.html

JordanMarr commented 2 years ago

That sounds weird.

  1. how about if you create them with a long .Create(col1, ...)("test") ?
  2. could this be that your transactions block the visibility somehow?

It does sound like a connection or a transaction is not being closed or disposed.

arnesahlberg commented 2 years ago

Thank you for your comments.

I've figured out the problem. It turns out it wasn't an SQLProvider issue, but an issue with the application content not being reloaded as it should.

Closing issue.