-
Notifications
You must be signed in to change notification settings - Fork 1
Table Valued Parameters
Jacek Hełka edited this page Mar 31, 2024
·
7 revisions
TVP support is part of DbFun extension for Microsoft SQL Server: DbFun.MsSql.
The configuration is simple - instead of DbFun.Core.Builders namespace open DbFun.MsSql.Builders.
Then, assuming, that you have user-defined table type:
create type dbo.Tag as table (
postId int not null,
name nvarchar(50) not null
)you can use TVPs either explicitly:
let updateTags = query.Sql(
"delete from tag where postId = @id;
insert into tag (postId, name) select @id, name from @tags",
Params.Int("id"), Params.TableValuedList(TVParams.Tuple<int, string>("postId", "name"), "tags", "Tag"),
Results.Unit)or implicitly - in this case TVP must be defined as a collection of records of type name the same, as corresponding user-defined table type name.
