scanhaser.blogg.se

Scriptcase master detail on new record
Scriptcase master detail on new record









This is a shell to create any kind of TVP This requires the using and using Dapper.Tvp. INSERT INTO OrderDetails (OrderId, CustomerId, ItemId, Quantity)įROM in C#, I would suggest creating methods for creating your TVP. INSERT INTO OrdersMaster (CustomerId) VALUES INT The procedure might look like this CREATE PROC Insert_Order_With_Details List_Of_Items You may need a table-valued type to pass in a list of data, like this: CREATE TYPE List_Of_Items AS TABLE ( I would implement the insert operations as a transactional stored procedure, and then call that from your. Var affectedRows = connection.Execute("insert into OrderDetails.", paramDetails, transaction: transaction) Use suitable loop as you want to insert multiple records. NewId = Convert.ToInt64(connection.ExecuteScalar("SELECT null, transaction: transaction)) If this is not an Identity, use different method here Get the Id newly created for master table record. Var affectedRows = connection.Execute("insert into OrdersMaster.", paramMaster, transaction: transaction) Using (var transaction = connection.BeginTransaction()) using (var connection = new SqlCeConnection("connection_string"))

#Scriptcase master detail on new record code

Though code is not complete, I have put detailed comments to explain steps. Please refer this question for discussion about that I have used in below code. Code below assumes you are using Identity as Primary Key.

scriptcase master detail on new record

This way, either all the changes will be committed or rolled back. My answer implements the same without Stored Procedure.

scriptcase master detail on new record scriptcase master detail on new record

Using stored procedure as mentioned in other answer is good solution.









Scriptcase master detail on new record