Show / Hide Table of Contents

    IDataStore<TModel>.GetItemStatus<TModel>(int row, Expression<Func<TModel, object>> selector, DwBuffer dwbuffer = DwBuffer.Primary) Method

    .NET Standard 2.x

    Gets the modification status of a column (specified by an expression) within a row in the specified buffer. The modification status determines the type of SQL statement the Update method will generate for the row or column.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Syntax

      public PropertyState GetItemStatus<TModel>(int row, Expression<Func<TModel, object>> selector, DwBuffer dwbuffer = DwBuffer.Primary);
    

    Type Parameters

    TModel

    The type of a model class that matches with the current DataObject.

    A value of the PropertyState enumerated datatype.

    Parameters

    row System.Int32

    The zero-based row number to get status.

    selector System.Linq.Expressions.Expression<Func<TModel, object>>

    An expression used to specify the column.

    bufferType DWNet.Data.DwBuffer

    The specified buffer of the DataStore. The default is DwBuffer.Primary.

    Returns

    SnapObjects.Data.PropertyState

    A value of the PropertyState enumerated datatype.

    Remarks

    Use the GetRowStatus method and the GetItemStatus method to understand what SQL statements will be generated for the new and changed information when you update the database.

    For rows in the primary and filter buffers, Update generates an INSERT statement for rows with ModelState.NewModified status; and generates an UPDATE statement for rows with ModelState.Modified status and references the columns that have been affected.

    For rows in the delete buffer, Update does not generate a DELETE statement for rows whose status was ModelState.New or ModelState.NewModified before being moved to the delete buffer.

    Examples

    The following code example demonstrates how to get the status of a column (specified by an expression).

    using Appeon.ApiDoc.Models;
    using DWNet.Data;
    using System;
    
    namespace Appeon.ApiDoc.IDataStore_GenericExamples
    {
        public class GetItemStatusExample
        {
            private readonly SchoolContext _context;
    
            public GetItemStatusExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore<D_Department>(_context);
    
                datastore.Retrieve();
    			
    			// Sets the Name column in the first row to New Department.
                datastore.SetItem(0, a => a.Name, "Department Name");
    
                Console.WriteLine(
                    "Department ID Status:{0};\n" +
                    "Department Name Status:{1}",
                    datastore.GetItemStatus(0, d => d.Departmentid),
                    datastore.GetItemStatus(0, d => d.Name, DwBuffer.Primary));
    
                /*This code produces the following output:
                 
                Department ID Status: NotModified;
                Department Name Status: Modified
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon