Show / Hide Table of Contents

    DynamicModel.IndexOf(string name) Method

    .NET Standard 2.x

    Gets the zero-based index of the property specified by the property name.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public int IndexOf(string name)
    

    Parameters

    name System.String

    The name of the property for which you want to get the zero-based index.

    Returns

    System.Int32

    Examples

    The following code example gets the index of the specified property in the DynamicModel object.

    using SnapObjects.Data;
    using System;
    
    namespace Appeon.ApiDoc.DynamicModelExamples
    {
        public class IndexOfExample
        {
            private readonly SchoolContext _context;
    
            public IndexOfExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example()
            {
                string sql;
    
                sql = "select * from Course";
                DynamicModel dynamicModel =
                    _context.SqlExecutor.SelectOne<DynamicModel>(sql);
    
                // Gets the index of the "Title" property
                int index = dynamicModel.IndexOf("Title");
                Console.WriteLine("Title's index = {0}", index);
    
                /* The code example produces the following output:
                
                Title's index = 1
                */
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon