Show / Hide Table of Contents

    DataStoreExtensions.SetValues(string column, object value, DwBuffer bufferType = DwBuffer.Primary) Method

    .NET Standard 2.x

    Sets the data value for the specified column in the specified buffer.

    Namespace: PowerScript.Bridge

    Assembly: PowerScript.Bridge.dll

    Syntax

    public static void SetValues(this IDataStoreBase dataStore, string column, object value, DwBuffer bufferType = DwBuffer.Primary);
    

    Parameters

    column System.String

    The column where you want to set values.

    value System.Object

    The data values to be set. The value can be a single record or a record set.

    When it is a single record, it will be set to the first row. When it is a record set, it will be set to the column of a range of rows.

    bufferType DwNet.Data.DwBuffer

    The buffer where the data value will be set.

    Examples

    The following code example demonstrates how to use the SetValues method to set the values of the Name column in all rows in the primary buffer of DataStore.

    using System;
    using DWNet.Data;
    using PowerScript.Bridge;
    using Appeon.ApiDoc.Models;
    
    namespace Appeon.ApiDoc.DataStoreExtensionsExamples
    {
        public class SetValuesExample
        {
            private readonly SchoolContext _context;
    
            public SetValuesExample(SchoolContext dataContext)
            {
                // Sets the data context
                _context = dataContext;
            }
    
            public void Example1()
            {
                // Instantiates a DataStore object with datawindow: d_department.
                var datastore = new DataStore("d_department", _context);
    
                // Retrieves data.
                datastore.Retrieve();
    
                // Creates a new string array of names.
                string[] names = new string[] { "new_name1", "new_name2", "new_name3", "new_name4"};
    
                // Sets the values of the Name column in the primary buffer of DataStore.
                datastore.SetValues("Name", names, DwBuffer.Primary);
    
                for (int i = 0; i < datastore.RowCount; i++)
                {
                    string name = datastore.GetItem<string>(i, "Name");
    
                    Console.WriteLine($"Name={name}");
                }
    
                /*This code produces the following output:
                
                Name=new_name1
                Name=new_name2
                Name=new_name3
                Name=new_name4
                */
            }
        }
    }
    

    Example Refer To

    Model Class: D_Department
    DataWindow File: d_department

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon