DataStoreExtensions.SetRowsData(object value, DwBuffer bufferType = DwBuffer.Primary) Method
.NET Standard 2.x
Sets the data value for the specified rows in the specified buffer of DataStore.
Namespace: PowerScript.Bridge
Assembly: PowerScript.Bridge.dll
Syntax
public static void SetRowsData(this IDataStoreBase dataStore, object value, DwBuffer bufferType = DwBuffer.Primary);
Parameters
value
System.Object
The data values to be set.
bufferType
DwNet.Data.DwBuffer
The specified buffer of the DataStore. The default is DwBuffer.Primary
.
Examples
The following code example demonstrates how to use the SetRowsData
method to set the data values for multiple 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 SetRowsDataExample
{
private readonly SchoolContext _context;
public SetRowsDataExample(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.
datastore.Retrieve();
// Creates a new D_Department object.
var models = new D_Department[4] {
new D_Department(){ Departmentid = 10, Name = "name1"},
new D_Department(){ Departmentid = 20, Name = "name2"},
new D_Department(){ Departmentid = 30, Name = "name3"},
new D_Department(){ Departmentid = 40, Name = "name4"},
};
// Sets the data values in the primary buffer of DataStore.
datastore.SetRowsData(models, DwBuffer.Primary);
for (int i = 0; i < datastore.RowCount; i++)
{
int departmentid = datastore.GetItem<int>(i, "Departmentid");
string name = datastore.GetItem<string>(i, "Name");
Console.WriteLine($"models[{i}].Departmentid={departmentid}, " +
$"models[{i}].Name={name}");
}
/*This code produces the following output:
models[0].Departmentid=10, models[0].Name=name1
models[1].Departmentid=20, models[1].Name=name2
models[2].Departmentid=30, models[2].Name=name3
models[3].Departmentid=40, models[3].Name=name4
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x