[SQL SERVER] Dealing with nulls values and timestamp columns during insert
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia con il percorso SQL Server usando localCtx.Dbo.WriteStorages.Create(x.ColumnValues), quindi verifica come vengono gestiti i valori null e le colonne timestamp durante gli inserimenti. Il lavoro è completato quando la sincronizzazione può inserire questi record senza sostituire i null con DBNull.Value o filtrare manualmente le colonne timestamp.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
As an exercise I've ported a small console application that sync tables in SQL SERVER DB from C# EF to F# SQLProvider.
In C# I was able to do the following:
foreach (Type t in types)
{
List<object> remoteEntities = await remoteContext.Set(t).ToListAsync();
var localEntities = await localContext.Set(t).ToListAsync();
localContext.Set(t).RemoveRange(localEntities);
localContext.Set(t).AddRange(remoteEntities);
}
await localContext.SaveChangesAsync();
In F# It became something like this:
...deleting old entities...
remoteCtx.Dbo.WriteStorages |> Seq.map (fun x-> localCtx.Dbo.WriteStorages.Create(x.ColumnValues)) |> Seq.toList
Actual behavior
This approach was failing due to 2 errors:
-
null had to be replaced with
System.DBNull.Valueand it was producing errors like:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll: 'The parameterized query '(@param0 uniqueidentifier,@param1 datetime,@param2 nvarchar(14),' expects the parameter '@param3', which was not supplied.' -
should filter Timestamp column from ColumnValues because of errors like:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll: 'Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.'
For EF It's working out-of-box, so maybe SQLProvider could also take care of these cases?
Known workarounds
Do the replacements mentioned above.
Related information
- SQL SERVER
- Windows
- .NET Runtime
- Lingua principale
- F#
- Stelle
- 627
- Fork
- 147
- Merge medio
- 2h 2m
- PR unite (30g)
- 1
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di fsprojects/SQLProvider
-
enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 55/100
fsprojects/SQLProvider#872 · 2 commenti ·
-
Repo Assist? Apertaenhancement
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
fsprojects/SQLProvider#870 · 1 commento ·
-
postgresql
Difficoltà 4/5 3-5 giorni Idoneità per principianti 58/100
fsprojects/SQLProvider#869 · 2 commenti ·
-
documentation
Difficoltà 2/5 1-3 ore Idoneità per principianti 42/100
fsprojects/SQLProvider#868 · 2 commenti ·
-
sql server
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
fsprojects/SQLProvider#851 · 1 commento ·
Tutte le issue di fsprojects/SQLProvider
Issue simili
-
bug: AI Gateway client filter lists "Unknown" twice when NULL and literal Unknown clients coexist Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
[BUG] A column whose default is the empty string is drawn in the ER diagram as having no default Apertabug database-provider good first issue hacktoberfest
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
libredb/libredb-studio#1030 · 6 commenti ·
-
comp-datalake
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
ClickHouse/ClickHouse#121222 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
bug redshift
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100