IDataStoreBase.RowsCopy(int startrow, int endrow, DwBuffer copybuffer, IDataStoreBase targetdw, int beforerow, DwBuffer targetbuffer) Method
.NET Standard 2.x
Copies a range of rows from one DataStore to another, or from one buffer to another within a single DataStore.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool RowsCopy(int startrow, int endrow, DwBuffer copybuffer, IDataStoreBase targetdw, int beforerow, DwBuffer targetbuffer);
Parameters
startrow
System.Int32
The zero-based index number of the first row you want to copy.
endrow
System.Int32
The zero-based index number of the last row you want to copy.
copybuffer
DWNet.Data.DwBuffer
A value of the DwBuffer
enumerated datatype identifying the DataWindow buffer
from which you want to copy rows.
targetdw
DWNet.Data.IDataStoreBase
A reference to the DataStore to which you want to copy the rows. targetDw
can be the current DataStore or another DataStore.
beforerow
System.Int32
The zero-based index number of the row before which you want to insert the copied rows. To insert after the last row, use any value that is greater than the number of existing rows.
targetbuffer
DWNet.Data.DwBuffer
A value of the DwBuffer
enumerated datatype identifying the target DataWindow buffer
into which you want to copy rows.
Returns
System.Boolean
Returns true
if it succeeds, and false
if any row number is not correct.
Remarks
When you use the RowsCopy
method, the status of the rows that are copied to the primary buffer is ModelState.NewModified
. If you issue an update request, DataStore sends SQL INSERT statements to the DBMS for the new rows.
When you use the RowsCopy
method, data is not automatically retrieved for drop-down DataWindows in the target DataStore, as it is when you call InsertRow
. You must explicitly call Retrieve
for DataWindowChilds
in the target.
When you use the RowsCopy
method or the RowsMove
method to populate another DataStore, the copied data is not automatically processed by the filter or sort criteria in effect on the target DataStore. You might be required to call the Filter
method or the Sort
method to properly process the data.
Uses for RowsCopy
: Making copies of one or more rows so that the users can create new rows based on the existing data.
Examples
The following code example demonstrates how to use the RowsCopy
method to copy rows from one DataStore to another.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class RowsCopyExample
{
private readonly SchoolContext _context;
public RowsCopyExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example()
{
// Instantiates a DataStore object with datawindow: d_department.
var dsFrom = new DataStore("d_department", _context);
// Instantiates another DataStore object with datawindow: d_department.
var dsTo = new DataStore("d_department", _context);
dsFrom.Retrieve();
dsTo.Retrieve();
Console.WriteLine("Before RowsCopy, Rowcount: {0}",
dsTo.RowCount);
// Calls RowsCopy to copy all rows from datastorefm to
// the beginning of the primary buffer of datastoreto
dsFrom.RowsCopy(0, dsFrom.RowCount, DwBuffer.Primary,
dsTo, 0, DwBuffer.Primary);
Console.WriteLine("After RowsCopy, Rowcount: {0}",
dsTo.RowCount);
/*This code produces the following output:
Before RowsCopy, Rowcount: 4
After RowsCopy, Rowcount: 8
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x