In the "create" view there is a form in which there are two fields: the date and the document number.

They are common to all lines, and you can clone 2 fields number and name using the button + line (the cloning function works), using the loop in this function, I created 100 lines to fill in (number and names).

On the server in the Post method, I accept all form values ​​using the Form Collection.

Here I implement adding rows to the server using a table parameter:

DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(int)); dt.Columns.Add("Name", typeof(string)); for (int i = 1; i <= rowCount; i++) dt.Rows.Add(i, $"Name {i}"); using (var cmd = new SqlCommand()) { cmd.Connection = connection; cmd.CommandText = @"insert into [Table] (ID, Name) select ID, Name from @data"; var p = new SqlParameter("@data", SqlDbType.Structured); p.TypeName = "dbo.TableType"; p.Value = dt; cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); } 

Actually how to measure the execution time of this monster?

    1 answer 1

    • From the code side:

       Stopwatch watch = new Stopwatch(); watch.Start(); // Код watch.Stop(); var elapsedTime = watch.Elapsed; 
    • From the database side - a database profiler.

    • From the browser side, see the request execution time in the developer panel on the network tab.
    • In general, yes. Only accounting for overhead is added. If you are interested in exactly the time of the query, then the best option is to use the database toolkit. - Artyom Okonechnikov
    • profiler put separately from sql server? - G.Fomin
    • If you are interested in the speed of the query, then this metric shows SSMS. If you need to see what steps the query performs and what it spends time, then use the Execution Plan tab - Artyom Okonechnikov
    • For more serious query tracing use profiler - msdn.microsoft.com/ru-ru/library/ms181091.aspx - Artem Okonechnikov
    • Ideally it would be from pressing the submit button on the view to writing 100 rows to a table on the server. - G.Fomin