I created a custom table type in SQL Server:
CREATE TYPE dbo.TestType AS TABLE ( ColumnA int, ColumnB nvarchar(500) )
And I use the stored procedure to insert records into the database:
create procedure [dbo].[sp_Test_CustomType] @testing TestType READONLY as insert into [dbo].[myTable] select ColumnA, ColumnB from @testing
And I would like to use EF to execute this stored procedure, but here's the problem: how can I pass a user-defined table to a stored procedure?
I tried to add the stored procedure to the model, but I could not find the desired stored procedure in the updated context.
What I'm trying to do is do a bulk insert into a table, here is the method I'm using now:
List<items> itemToInsertToDB =
I am currently using the foreach to cycle through the list to insert an item in the database, but if there are a lot of items in the list, then there will be a performance problem, so I think about passing the list to the stored procedure and doing an internal insert.
So how to solve this problem? or are there any better ways to do this?
c # sql sql-server stored-procedures entity-framework
User2012384
source share