Answer the question
In order to leave comments, you need to log in
How to pass multiple rows of data to a stored procedure?
Hello.
There are 2 HP. One returns data, the second data must be transferred.
Both work with collections of data.
With HP which returns the data understood. Because I work with .NET Core, and it does not have a DataTable, I had to create my own wrapper class for the returned data. Essentially I have a multidimensional data array. With this, everything is clear.
A question on , which should accept these data.
SqlParameter allows you to create a parameter and pass data to it. It's not a problem. I don't know how to pass an array of data.
Tell me please.
Answer the question
In order to leave comments, you need to log in
In .NET Core, DataTable is replaced with List<SqlDataRecord>
Example:
private SqlParameter CreateTableGuidParameter(string name, Guid[] ids)
{
var tableParam = new SqlParameter(name, SqlDbType.Structured);
tableParam.TypeName = "[dbo].[TableUniqueIdentifierType]";
tableParam.Direction = ParameterDirection.Input;
var rows = new List<SqlDataRecord>();
var sqlMetaData = new SqlMetaData("Id", SqlDbType.UniqueIdentifier);
foreach (var id in ids)
{
var row = new SqlDataRecord(sqlMetaData);
row.SetValues(id);
rows.Add(row);
}
tableParam.Value = rows;
return tableParam;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question