[SQL SERVER] Dealing with nulls values and timestamp columns during insert
还没有人认领这个 Issue。
评估
调研方向
从使用 localCtx.Dbo.WriteStorages.Create(x.ColumnValues) 的 SQL Server 路径开始,然后检查插入期间如何处理 null 值和 timestamp 列。完成标准是同步可以插入这些记录,而无需将 null 替换为 DBNull.Value,也无需手动筛选 timestamp 列。
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- F#
- 星标
- 627
- 派生
- 147
- 平均合并
- 2 小时 2 分钟
- 30 天内合并 PR
- 1
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
fsprojects/SQLProvider 的其他 Issue
-
enhancement
难度 3/5 1-2 天 新手友好度 55/100
fsprojects/SQLProvider#872 · 2 条评论 ·
-
Repo Assist? 未关闭enhancement
难度 5/5 一周以上 新手友好度 10/100
fsprojects/SQLProvider#870 · 1 条评论 ·
-
postgresql
难度 4/5 3-5 天 新手友好度 58/100
fsprojects/SQLProvider#869 · 2 条评论 ·
-
documentation
难度 2/5 1-3 小时 新手友好度 42/100
fsprojects/SQLProvider#868 · 2 条评论 ·
-
sql server
难度 4/5 3-5 天 新手友好度 45/100
fsprojects/SQLProvider#851 · 1 条评论 ·
查看 fsprojects/SQLProvider 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 90/100
-
难度 2/5 1-3 小时 新手友好度 68/100
community-scripts/ProxmoxVE#17396 · 1 条评论 ·
-
bug possible-duplicate
难度 2/5 1-3 小时 新手友好度 88/100
AOSSIE-Org/PictoPy#1553 · 4 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
BasedHardware/omi#15274 · 3 条评论 ·
-
难度 2/5 1-3 小时 新手友好度 88/100