Show / Hide Table of Contents

    DataWindowAttribute Class

    .NET Standard 2.x

    Specifies the DataWindow object name and presentation style for the model.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Inheritance Constructor

    System.Attribute

    Syntax

        [AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
        public class DataWindowAttribute : Attribute
    

    Constructors

    Name Description
    DataWindowAttribute(string dataObjectName, DwStyle processing ) Initializes a new instance of the DataWindowAttribute class.

    Properties

    Name Return Type Description
    DataObjectName string DataWindow object name
    Processing DWNet.Data.DwStyle DataWindow object presentation style

    Remarks

    Sets the DataWindow object name and presentation style for the model. Processing will use DwStyle enumeration.

    Examples

    The following code example demonstrates how to use the DataWindow attribute. DataStore(string dataObject) defines the DataStore by matching the name specified by dataObject with the DataObjectName in DataWindowAttribute of the Model. If a match is found, then the Model will be used.

    Model: D_Department
    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;
    
    namespace Appeon.ApiDoc.Models
    {
        [DataWindow("d_department", DwStyle.Grid)]
        [Table("Department", Schema = "dbo")]
        #region DwSelectAttribute  
        [DwSelect("PBSELECT( VERSION(400) TABLE(NAME=\"Department\" ) @(_COLUMNS_PLACEHOLDER_) )")]
        #endregion
        [UpdateWhereStrategy(UpdateWhereStrategy.KeyAndConcurrencyCheckColumns)]
        [DwKeyModificationStrategy(UpdateSqlStrategy.DeleteThenInsert)]
        [DwTemplate(DataFormat.Xml, "xml_default", "Templates\\xml_setparameter_default.xml", IsDefault = true)]
        public class D_Department
        {
            [Key]
            [DwColumn("Department", "DepartmentID")]
            public int Departmentid { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Department", "Name")]
            public string Name { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Department", "Budget")]
            public decimal Budget { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Department", "StartDate")]
            public DateTime Startdate { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Department", "Administrator")]
            public int? Administrator { get; set; }
    
        }
    
    }
    
    Example Method:
    using System;
    using DWNet.Data;
    
    namespace Appeon.ApiDoc.DataWindowAttributeExamples
    {
        public class DataWindowAttributeExample
        {
            private readonly SchoolContext _context;
    
            public DataWindowAttributeExample(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);
    
                // Retrieves data from the database for datastore
                datastore.Retrieve();
    
                Console.WriteLine("After Retrieve, Rowcount: {0}",
                    datastore.RowCount);
    
                /*This code produces the following output:
                
                After Retrieve, Rowcount: 4
                */
    
            }
        }
    }
    

    Example Refer To

    DataWindow File: d_department

    Back to top Generated by Appeon