Show / Hide Table of Contents

    DynamicModel.Item[Int32] Property

    .NET Standard 2.x

    Gets or sets the value of the property at the specified index.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public object this[int index] { get; set; }
    

    Parameters

    index System.Int32

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

    Property Value

    System.Object

    The value of the specified property.

    Examples

    The following code example demonstrates how to use the DynamicModel.Item[Int32] property to get the value at the specified index.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.DynamicModelExamples
    {
        public class ItemExample
        {
            private readonly SchoolContext _context;
    
            public ItemExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
    
            public void Example1()
            {
                string sql;
    
                sql = "select CourseId, Title, Credits, DepartmentID from Course";
    
                // Retrieves and gets a DynamicModel object which contains the first 
                // row of the result set.
                var dynamicModel = _context.SqlExecutor.SelectOne<DynamicModel>(sql);
    
                // Gets Title by the property index.
                var title = (string)dynamicModel[1];
    
                Console.WriteLine("Title: {0}", title);
    
                // Gets Credits by the property index.
                var credits = (int)dynamicModel[2];
    
                Console.WriteLine("Credits: {0}", credits);
    
                /*This code produces the following output:
    
                Title: Calculus
                Credits: 4
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon