IDataStore.DeleteRow(int row) Method
.NET Standard 2.x
Deletes the specified row (by the index number) from the primary buffer of the DataStore. The deleted row will be moved to the delete buffer of the DataStore.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool DeleteRow(int row);
Parameters
row
System.Int32
A zero-based index number of the row to delete from the primary buffer of the DataStore.
Returns
System.Boolean
Always returns true
except for when exceptions are thrown.
Remarks
The DeleteRow
method deletes a row from the DataStore primary buffer. If DataStore is not updatable, the storage related with the deleted row will be directly erased. If DataStore is updatable, DeleteRow
moves the row to the delete buffer. DataStore uses the value in the delete buffer to create the SQL DELETE statement. The row will not be deleted from the database table until Update
method is called; and the storage related with the deleted row will not be erased until the database is updated with the changes made to the DataStore and the update flag is reset by the Update
method.
Examples
The following code example demonstrates how to use the DeleteRow(int)
method to move a row from the primary buffer to the delete buffer.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class DeleteRowExample
{
private readonly SchoolContext _context;
public DeleteRowExample(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);
datastore.Retrieve();
// This datastore has 4 records
Console.WriteLine("Retrieved Rowcount: {0}", datastore.RowCount);
// Deletes the first row.
datastore.DeleteRow(0);
// This datastore has 3 records in the primary buffer.
Console.WriteLine("Primary buffer Rowcount: {0}",
datastore.RowCount);
// This datastore has 1 record in the delete buffer.
Console.WriteLine("Delete buffer Rowcount: {0}",
datastore.DeletedCount);
/*This code produces the following output:
Retrieved Rowcount: 4
Primary buffer Rowcount: 3
Delete buffer Rowcount: 1
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x