Show / Hide Table of Contents

    ParamValue.ReturnValue<TType>(string name) Method

    .NET Standard 2.x

    Creates a new ParamValue object as the return value of a stored procedure.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public static ParamValue ReturnValue<TType>(string name)
    

    Type Parameters

    TType

    The datatype of the return value.

    Parameters

    name System.String

    The name of the return value.

    Returns

    SnapObjects.Data.ParamValue

    Returns a newly created ParamValue object.

    Examples

    The following code Creates a new ParamValue object as the return value of a stored procedure.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Threading.Tasks;
    using Appeon.ApiDoc;
    using SnapObjects.Data;
    
    namespace Appeon.ApiDoc.ParamValueExamples
    {
        public class ReturnValueExample
        {
            private readonly SchoolContext _context;
            
            public ReturnValueExample(SchoolContext context)
            {
                _context = context;
            }
    
            public async void Example1()
            {
                // Specifies the procedure to be executed.
                string procedureName = "GetDepartmentName";
                
                ParamValue idParam = ParamValue.Input<string>("id", "4");
                
                ParamValue nameParam = ParamValue.Output<string>("name");
                
                // The parameter 'Name' is ReturnValue type.
                ParamValue returnParam = ParamValue.ReturnValue<string>("name");
                
                // Gets and shows the attribute value of the ParamValue object
                Console.WriteLine("returnParam.Name = {0}", returnParam.Name);
                Console.WriteLine("returnParam.Direction = {0}\n", returnParam.Direction);
                
                Console.WriteLine("Before Executes the SQL statement:");
                Console.WriteLine("returnParam.Value = {0}\n", returnParam.Value);
                
                
                // Asynchronously Executes the SQL statement and gets the department by
                // nameParam.
                int rowAffected = await _context.SqlExecutor.ExecuteProcedureAsync(
                        procedureName, idParam, nameParam, returnParam);
                        
                Console.WriteLine("After Executes the SQL statement:");
                Console.WriteLine("returnParam.Value = {0}", returnParam.Value);
                
                /*This code produces the following output:
                
                    ParamValue.Name = name
                    ParamValue.Direction = ReturnValue
                    
                    Before Executes the SQL statement:
                    ParamValue.Value =
                    
                    After Executes the SQL statement:
                    ParamValue.Value = Economics
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon