Show / Hide Table of Contents

    DwUpdateParameterAttribute Class

    .NET Standard 2.x

    Specifies the parameter of the method used by the insert, delete, or update operation.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Inheritance Constructor

    System.Attribute

    Syntax

        [AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
        public class DwUpdateParameterAttribute : Attribute
    

    Constructors

    Name Description
    DwUpdateParameterAttribute(DwUpdateAction action, DwArgumentSource source, string name, string expression) Initializes a new instance of the DwUpdateParameterAttribute class.

    Properties

    Name Return Type Description
    Action DwUpdateAction The operation corresponding to the parameter.
    Direction ParameterDirection The direction type of the parameter.
    Expression string The expression of the parameter.
    Name string The name of the parameter.
    Source DwArgumentSource The data source for the parameter.
    UseOriginal bool Whether to use the original data.

    Remarks

    This class corresponds to the parameter of the Stored Procedure Update method defined by DataWindow.

    Examples

    The following code example demonstrates how to use the Model DwUpdateParameter attribute. The example enables the DwUpdateParameter attribute which defines the parameters used by the stored procedure in DwUpdate.

    Model: D_Person_With_Deleteaction
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.ComponentModel.DataAnnotations.Schema;
    using SnapObjects.Data;
    using DWNet.Data;
    using Newtonsoft.Json;
    using System.Collections;
    
    namespace Appeon.ApiDoc.Models
    {
        [DataWindow("d_person_with_deleteaction", DwStyle.Grid)]
        [Table("Person")]
        #region DwSelectAttribute  
        [DwSelect("PBSELECT( VERSION(400) TABLE(NAME=\"Person\" ) @(_COLUMNS_PLACEHOLDER_) )")]
        #endregion
        [DwUpdate(DwUpdateAction.Delete, "dbo.DeletePerson;1")]
        [DwUpdateParameter(DwUpdateAction.Delete, DwArgumentSource.Column, "PersonID", "personid", UseOriginal = true, Direction = System.Data.ParameterDirection.Input)]
        [DwKeyModificationStrategy(UpdateSqlStrategy.DeleteThenInsert)]
        [UpdateWhereStrategy(UpdateWhereStrategy.KeyAndConcurrencyCheckColumns)]
        public class D_Person_With_Deleteaction
        {
            [Key]
            [Identity]
            [DwColumn("Person", "PersonID")]
            public int Personid { get; set; }
    
            [ConcurrencyCheck]
            [StringLength(50)]
            [DwColumn("Person", "LastName")]
            public string Lastname { get; set; }
    
            [ConcurrencyCheck]
            [StringLength(50)]
            [DwColumn("Person", "FirstName")]
            public string Firstname { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Person", "HireDate")]
            public DateTime? Hiredate { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Person", "EnrollmentDate")]
            public DateTime? Enrollmentdate { get; set; }
    
            [ConcurrencyCheck]
            [StringLength(50)]
            [DwColumn("Person", "Discriminator")]
            public string Discriminator { get; set; }
    
        }
    
    }
    
    Example Method:
    using DWNet.Data;
    
    namespace Appeon.ApiDoc.DwUpdateParameterAttributeExamples
    {
        public class DwUpdateParameterAttributeExample
        {
            private readonly SchoolContext _context;
    
            public DwUpdateParameterAttributeExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
    
            public void Example()
            {
                var datastore = new DataStore("d_person_with_deleteaction", _context);
                datastore.Retrieve();
    			
    			//Deletes the first row from the primary buffer of DataStore.
                datastore.DeleteRow(0);
    			
    			//Commits the changes to the DataStore.
                datastore.Update();
    
                /* The following SQL is generated:
                exec dbo.DeletePerson @PersonID=1
                
                */
            }
        }
    }
    

    Example Refer To

    DataWindow File: d_person_with_deleteaction

    Back to top Generated by Appeon