Show / Hide Table of Contents

    DwReportAttribute Class

    .NET Standard 2.x

    Specifies the child report.

    Namespace: DWNet.Data

    Assembly: DWNet.Data.dll

    Inheritance Constructor

    System.Attribute

    Syntax

      [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)]
      public class DwReportAttribute : Attribute
    

    Constructors

    Name Description
    DwReportAttribute(Type modelType) Initializes a new instance of the DwReportAttribute class.

    Properties

    Name Return Type Description
    ModelType Type The model type for the child report.
    ParamValues string The parameter values for the child report.

    Remarks

    Corresponding to the report defined by DataWindow.

    Examples

    The following code example demonstrates how to use the Model DwReport attribute to include a nested report, and use Getitem to get the nested report.

    Model: D_Department_With_Report
    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_department_with_report", DwStyle.Default)]
        [Table("Department")]
        #region DwSelectAttribute  
        [DwSelect("PBSELECT( VERSION(400) TABLE(NAME=\"Department\" ) @(_COLUMNS_PLACEHOLDER_) )")]
        #endregion
        [DwSort("departmentid A")]
        [DwKeyModificationStrategy(UpdateSqlStrategy.DeleteThenInsert)]
        [UpdateWhereStrategy(UpdateWhereStrategy.KeyAndConcurrencyCheckColumns)]
        public class D_Department_With_Report
        {
            [Key]
            [DwColumn("Department", "DepartmentID")]
            public int Departmentid { get; set; }
    
            [ConcurrencyCheck]
            [StringLength(50)]
            [DwColumn("Department", "Name")]
            public string Name { get; set; }
    
            [JsonIgnore]
            [DwReport(typeof(D_Course_With_Param), ParamValues = "departmentid")]
            public IList<D_Course_With_Param> Dw_1 { get; set; }
    
        }
    
    }
    
    Model: D_Course_With_Param
    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_course_with_param", DwStyle.Grid)]
        [Table("Course")]
        #region DwSelectAttribute  
        [DwSelect("PBSELECT( VERSION(400) TABLE(NAME=\"Course\" ) @(_COLUMNS_PLACEHOLDER_) WHERE(    EXP1 =\"Course.DepartmentID\"   OP =\"=\"    EXP2 =\":department_id\" ) ) ARG(NAME = \"department_id\" TYPE = number)")]
        #endregion
        [DwParameter("department_id", typeof(decimal?))]
        [DwSort("courseid A")]
        [DwKeyModificationStrategy(UpdateSqlStrategy.DeleteThenInsert)]
        [UpdateWhereStrategy(UpdateWhereStrategy.KeyAndConcurrencyCheckColumns)]
        public class D_Course_With_Param
        {
            [Key]
            [DwColumn("Course", "CourseID")]
            public int Courseid { get; set; }
    
            [ConcurrencyCheck]
            [StringLength(100)]
            [DwColumn("Course", "Title")]
            public string Title { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Course", "Credits")]
            public int Credits { get; set; }
    
            [ConcurrencyCheck]
            [DwColumn("Course", "DepartmentID")]
            public int Departmentid { get; set; }
    
        }
    
    }
    
    Example Method:
    using System;
    using System.Collections.Generic;
    using DWNet.Data;
    using Appeon.ApiDoc.Models;
    
    namespace Appeon.ApiDoc.DwReportAttributeExamples
    {
        public class DwReportAttributeExample
        {
            private readonly SchoolContext _context;
    
            public DwReportAttributeExample(SchoolContext dataContext)
            {
                // Sets the data context.
                _context = dataContext;
            }
    
            public void Example()
            {
                var datastore = new DataStore("d_department_with_report", _context);
                datastore.Retrieve();
    
                // Gets the nested report.
                var reports = datastore.GetItem<IList<D_Course_With_Param>>(0, "dw_1");
    
                // Shows the total number of rows in the nested report.
                Console.WriteLine($"report Count={reports.Count}.");
    
                /* This code example produces the following output:
                
                report Count=2.
                */
            }
        }
    }
    

    Example Refer To

    DataWindow Files: d_department_with_report d_course_with_param

    Back to top Generated by Appeon