Show / Hide Table of Contents

    DynamicModel.GetValue<TValue>(int index) Method

    .NET Standard 2.x

    Gets the value of the specified property (by index) in the DynamicModel object, and casts it to the specified data type.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

     public TValue GetValue<TValue>(int index)
    

    Type Parameters

    TValue

    The data type of the value you want to get from the specified property.

    Parameters

    index System.Int32

    The zero-based index of the property to get value.

    Returns

    TValue

    Returns the value of the specified property.

    Examples

    The following code example gets the property value at the specified index in the DynamicModel object and converts it to the specified data type.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.DynamicModelExamples
    {
        public class GetValueExample
        {
            private readonly SchoolContext _context;
    
            public GetValueExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example2()
            {
                string sql;
    
                sql = "select * from Course";
                DynamicModel dynamicModel =
                    _context.SqlExecutor.SelectOne<DynamicModel>(sql);
    
                // Gets the property value whose index=0
                int value = dynamicModel.GetValue<int>(0);
                Console.WriteLine("Value = {0}", value.ToString());
    
                /* The code example produces the following output:
                
                Value = 1045
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon