SPBP.procedure-pattern 1.0.3

Stored Procedure based Pattern

Stored procedure based pattern .  Used for load  , execute stored procedures in Ms SQl server  .

Install-Package SPBP.procedure-pattern -Version 1.0.3
dotnet add package SPBP.procedure-pattern --version 1.0.3
<PackageReference Include="SPBP.procedure-pattern" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SPBP.procedure-pattern --version 1.0.3
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Here is explanation of Console application code.

First of all you need to declare a DbAgent variable:

DbAgent agent = new DbAgent(name, connection string.state);

(If agent state isn't true it will throw an exception in procedure execution . )

Then get the all stored procedures existing in that DataBase:

ProcedureFactory fact = SqlManager.GetProceduresFactory(agent);

Select the Procedure:

DataSItem procedure = fact.Procedures[procedurename];

Set values to parameters if procedure needs :

  //fill params  values 
                    foreach (DataParam param in procedure.Params.Values)
                    {
                        if (param.Direction == ParamDirection.Input)
                        {
                            Console.Write(param.Name + : );
                            param.Value = Console.ReadLine();
                        }

                    }

Get output params after execution :

If procedure has output params it will be added to DsItem Output params .

 if (item.HasOutputParam)
                    {
                        foreach (DataParam prm in item.OutputParams.Values)
                        {
                            Console.WriteLine(prm.Name + = + prm.Value);
                        }
                    }

Get marked class collection :

IBag<Item> items;
ExecResult result = procedure.ExecuteDataReaderByRef(agent, out items);

OR

DataSet set = new DataSet();
procedure.ExecDataSet(agent, out set);

Here is explanation of Console application code.

First of all you need to declare a DbAgent variable:

DbAgent agent = new DbAgent(name, connection string.state);

(If agent state isn't true it will throw an exception in procedure execution . )

Then get the all stored procedures existing in that DataBase:

ProcedureFactory fact = SqlManager.GetProceduresFactory(agent);

Select the Procedure:

DataSItem procedure = fact.Procedures[procedurename];

Set values to parameters if procedure needs :

  //fill params  values 
                    foreach (DataParam param in procedure.Params.Values)
                    {
                        if (param.Direction == ParamDirection.Input)
                        {
                            Console.Write(param.Name + : );
                            param.Value = Console.ReadLine();
                        }

                    }

Get output params after execution :

If procedure has output params it will be added to DsItem Output params .

 if (item.HasOutputParam)
                    {
                        foreach (DataParam prm in item.OutputParams.Values)
                        {
                            Console.WriteLine(prm.Name + = + prm.Value);
                        }
                    }

Get marked class collection :

IBag<Item> items;
ExecResult result = procedure.ExecuteDataReaderByRef(agent, out items);

OR

DataSet set = new DataSet();
procedure.ExecDataSet(agent, out set);

Release Notes

Stored Procedure based pattern

Dependencies

This package has no dependencies.

Version History

Version Downloads Last updated
1.0.3 245 10/9/2017