IDataStoreBase.RowsDiscard(int startrow, int endrow, DwBuffer bufferType) Method
.NET Standard 2.x
Discards a range of rows in the DataStore. Once a row has been discarded using RowsDiscard
, you cannot restore the row unless you retrieve it again from the database.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool RowsDiscard(int startrow, int endrow, DwBuffer buffer);
Parameters
startrow
System.Int32
The zero-based index number of the first row you want to discard.
endrow
System.Int32
The zero-based index number of the last row you want to discard.
bufferType
DWNet.Data.DwBuffer
A value of the DwBuffer
enumerated datatype specifying the DataWindow buffer
containing the rows to be discarded.
Returns
System.Boolean
Returns true
if it succeeds, and false
if either startrow
or endrow
is not correct.
Remarks
Use the RowsDiscard
method when your application is finished with some of the rows in a DataStore and you do not want an update to affect the rows in the database. For example, you can discard rows in the delete buffer, which prevents the rows from being deleted when you call the Update
method.
Use the Reset
method to clear all the rows from a DataStore.
Examples
The following code example demonstrates how to use the RowsDiscard
method to delete multiple rows and keep only one row.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreBaseExamples
{
public class RowsDiscardExample
{
private readonly SchoolContext _context;
public RowsDiscardExample(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);
datastore.Retrieve();
Console.WriteLine("Before RowsDiscard, Rowcount: {0}",
datastore.RowCount);
// Calls RowsDiscard to discard a range of rows in DataStore, the
// discarded rows cannot be restored unless retrieved again from database.
datastore.RowsDiscard(0, datastore.RowCount - 2, DwBuffer.Primary);
Console.WriteLine("After RowsDiscard, PrimaryBuffer Rowcount: {0} ",
datastore.RowCount);
Console.WriteLine("After RowsDiscard, DeleteBuffer Rowcount: {0}",
datastore.DeletedCount);
/*This code produces the following output:
Before RowsDiscard, Rowcount: 4
After RowsDiscard, PrimaryBuffer Rowcount: 1
After RowsDiscard, DeleteBuffer Rowcount: 0
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x