Show / Hide Table of Contents

    DynamicModel.Item[String] Property

    .NET Standard 2.x

    Gets or sets the value of the specified property (by name).

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public object this[string columnName] { get; set; }
    

    Parameters

    columnName System.String

    The name of the property to get or set value.

    Returns

    System.Object

    The value of the specified property.

    Examples

    The following code example demonstrates how to use the DynamicModel.Item[String] property to get the value of the property specified by name.

    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 Example2()
            {
                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.
                var title = (string)dynamicModel["Title"];
    
                Console.WriteLine("Title: {0}", title);
    
                // Gets Credits.
                var credits = (int)dynamicModel["Credits"];
    
                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