Show / Hide Table of Contents

    ISqlModelMapper.Track(IMapperTrackable mapperTrackable, params object[] saveParms) Method

    .NET Standard 2.x

    Tracks an IMapperTrackable object. When ISqlModelMapper.SaveChanges method is called, the SaveChanges method of this object will be called.

    Namespace: SnapObjects.Data

    Assembly: SnapObjects.Data.dll

    Syntax

    public ISqlModelMapper Track(IMapperTrackable mapperTrackable, params object[] saveParms);
    

    Parameters

    mapperTrackable

    The IMapperTrackable object to be tracked.

    saveParms

    The parameters used by the SaveChanges method of IMapperTrackable.

    Returns

    SnapObjects.Data.ISqlModelMapper

    Returns the current ISqlModelMapper object, which can be used to execute other methods.

    Examples

    The following code example demonstrates how to track an IMapperTackable object. When saving the changes, it calls the SaveChanges method of the IMapperTrackable object, and commits the transaction at last.

    using SnapObjects.Data;
    using Appeon.ApiDoc.Models.School;
    using System;
    
    namespace Appeon.ApiDoc.ISqlModelMapperExamples
    {
        public class TrackExample
        {
            private SchoolContext _context;
    
            public TrackExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
    
            public void Example4(IMapperTrackable newStudent)
            {
                var mapper = _context.SqlModelMapper;
    
                // Tracks the IMapperTrackable object for the new student.
                // There is no implement for IMapperTrackable in this library.
                mapper.Track(newStudent);
    
                // When saving the changes, it calls the SaveChanges method of the IMapperTrackable object. 
                var dbResult = mapper.SaveChanges();
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon