Aspose.Words.Examples.CSharp.Mail_Merge.ApplyCustomLogicToEmptyRegions.GetDataSource C# (CSharp) Method

GetDataSource() private static method

Returns the data used to merge the TestFile document. This dataset purposely contains only rows for the StoreDetails region and only a select few for the child region.
private static GetDataSource ( ) : DataSet
return System.Data.DataSet
        private static DataSet GetDataSource()
        {
            // Create a new DataSet and DataTable objects to be used for mail merge.
            DataSet data = new DataSet();
            DataTable storeDetails = new DataTable("StoreDetails");
            DataTable contactDetails = new DataTable("ContactDetails");

            // Add columns for the ContactDetails table.
            contactDetails.Columns.Add("ID");
            contactDetails.Columns.Add("Name");
            contactDetails.Columns.Add("Number");

            // Add columns for the StoreDetails table.
            storeDetails.Columns.Add("ID");
            storeDetails.Columns.Add("Name");
            storeDetails.Columns.Add("Address");
            storeDetails.Columns.Add("City");
            storeDetails.Columns.Add("Country");

            // Add the data to the tables.
            storeDetails.Rows.Add("0", "Hungry Coyote Import Store", "2732 Baker Blvd", "Eugene", "USA");
            storeDetails.Rows.Add("1", "Great Lakes Food Market", "City Center Plaza, 516 Main St.", "San Francisco", "USA");

            // Add data to the child table only for the first record.
            contactDetails.Rows.Add("0", "Thomas Hardy", "(206) 555-9857 ext 237");
            contactDetails.Rows.Add("0", "Elizabeth Brown", "(206) 555-9857 ext 764");

            // Include the tables in the DataSet.
            data.Tables.Add(storeDetails);
            data.Tables.Add(contactDetails);

            // Setup the relation between the parent table (StoreDetails) and the child table (ContactDetails).
            data.Relations.Add(storeDetails.Columns["ID"], contactDetails.Columns["ID"]);

            return data;
        }
        private static DataTable orderTable = null;