Code generator for creating an SqlParemeter ADO.NET array from stored procedure inputs?

I have SQL Server stored procedures with multiple inputs. I want to save time by manually creating sqlParameter C # ADO.NET arrays, as in

sqlParameter[] sqlParameters = 
                { new SqlParameter("customerID", SqlDbType.Int, 4, ParameterDirection.Input, false, 0, 0, string.Empty, DataRowVersion.Default, custID) .......

Any code generator that can do this and a template that can do this? If you mention a code generator, specify which template. Like for CodeSmith .

+3
source share
4 answers

, Visual Studio (. this ). , , , .

DAL , , , ORM (Entity Framework, LINQ to SQL.. ..), .

0

DataSet, . Server Explorer .

:

  • A DataSet,
  • "QueriesTableAdapter".
  • .

, , . F7 ( ). DataSet1.cs. :

using System.Data.SqlClient;

namespace WebApplication.Data.DataSet1TableAdapters
{
    public partial class QueriesTableAdapter
    {
        public SqlCommand aspnet_Membership_CreateUser_Command
        {
            get { return (SqlCommand) CommandCollection[0]; }
        }
    }
}

( -, ASP.NET, )

QueriesTableAdapter.aspnet_Membership_CreateUser_Command.Parameters.

0

Check out my SqlSharpener project . It can parse sql files in your SSDT project at design time , and then you can call the included T4 template to create C # wrappers for all your stored procedures, or you can create your own T4 template if you want.

0
source

Source: https://habr.com/ru/post/1768520/


All Articles