Show / Hide Table of Contents

    IModelGetter Interface

    .NET Standard 2.x

    Represents the value getter of a model object. Used in conjunction with the grouping function of the DataStore.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public interface IModelGetter;
    

    Properties

    Name Return Type Description
    RowId int Gets the ID of the row in the DataStore corresponding to the model object.
    Value object The value of the model object. You can convert it to a TModel.

    Methods

    Name Return Type Description
    GetItem(short column, bool isOriginalValue = false) object Gets the value of the specified column (by column number).
    GetItem(string column, bool isOriginalValue = false) object Gets the value of the specified column (by column name).
    GetItem<TValue>(short column, bool isOriginalValue = false) TValue Gets the value of the specified column (by column number) and converts this value to the specified data type.
    GetItem<TValue>(string column, bool isOriginalValue = false) TValue Gets the value of the specified column (by column name) and converts this value to the specified data type.
    GetItemBoolean(short column, bool isOriginalValue = false) bool? Gets the value of the specified column (by column number) and converts this value to the System.Nullable<System.Boolean> data type.
    GetItemBoolean(string column, bool isOriginalValue = false) bool? Gets the value of the specified column (by column name) and converts this value to the System.Nullable<System.Boolean> data type.
    GetItemDate(short column, bool isOriginalValue = false) DateTime? Gets the value of the specified column (by column number) and converts this value to the System.Nullable<System.DateTime> data type.
    GetItemDate(string column, bool isOriginalValue = false) DateTime? Gets the value of the specified column (by column name) and converts this value to the System.Nullable<System.DateTime> data type.
    GetItemDateTime(short column, bool isOriginalValue = false) DateTime? Gets the value of the specified column (by column number) and converts this value to the System.Nullable<System.DateTime> data type.
    GetItemDateTime(string column, bool isOriginalValue = false) DateTime? Gets the value of the specified column (by column name) and converts this value to the System.Nullable<System.DateTime> data type.
    GetItemDecimal(short column, bool isOriginalValue = false) decimal? Gets the value of the specified column (by column number) and converts this value to the System.Nullable<System.Decimal> data type.
    GetItemDecimal(string column, bool isOriginalValue = false) decimal? Gets the value of the specified column (by column name) and converts this value to the System.Nullable<System.Decimal> data type.
    GetItemNumber(short column, bool isOriginalValue = false) double? Gets the value of the specified column (by column number) and converts this value to the System.Nullable<System.Double> data type.
    GetItemNumber(string column, bool isOriginalValue = false) double? Gets the value of the specified column (by column name) and converts this value to the System.Nullable<System.Double> data type.
    GetItemString(short column, bool isOriginalValue = false) string Gets the value of the specified column (by column number) and converts this value to the System.String data type.
    GetItemString(string column, bool isOriginalValue = false) string Gets the value of the specified column (by column name) and converts this value to the System.String data type.
    GetItemTime(short column, bool isOriginalValue = false) TimeSpan? Gets the value of the specified column (by column number) and converts this value to the System.Nullable<System.TimeSpan> data type.
    GetItemTime(string column, bool isOriginalValue = false) TimeSpan? Gets the value of the specified column (by column name) and converts this value to the System.Nullable<System.TimeSpan> data type.

    Examples

    The following code example creates an instance of ModelGetter.

    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IModelGetterExamples
    {
        public class IModelGetterExample
        {
            private readonly SchoolContext _context;
    
            public IModelGetterExample(SchoolContext context)
            {
                _context = context;
            }
    
            public void Example()
            {
                // Creates a datastore object
                IDataStore course = new DataStore("d_department_course", _context);
    
                course.Retrieve();
    
                var departmentGropup = course.GroupBy(1, null);
    
                // Gets the grouped data
                foreach (var m in departmentGropup)
                {
                    Console.WriteLine("Group Key = {0}", m.Key);
                    // Shows the data in each group in a loop
                    foreach (var getter in m)
                    {
                        Console.WriteLine("Course Name = {0}" , getter.GetItemString(1));
                    }
    
                }
    
                /*This code produces the following output:
                
                Group Key = 1
                Course Name = Chemistry
                Course Name = Chemistry
                Course Name = Chemistry
                Course Name = Physics
                Course Name = Physics
                Course Name = Physics
                Course Name = Physics
                Course Name = Physics
                Course Name = Physics
                Course Name = Physics
                Group Key = 2
                Course Name = Composition
                Course Name = Composition
                Course Name = Composition
                Course Name = Composition
                Course Name = Composition
                Course Name = Poetry
                Course Name = Poetry
                Course Name = Literature
                Course Name = Literature
                Course Name = Literature
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department_Course
    DataWindow File: d_department_course

    Back to top Generated by Appeon