IDataStore.Remove<TModel>(TModel item) Method
.NET Standard 2.x
Removes the specified row from the primary buffer of the DataStore.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool Remove<TModel>(TModel item);
Type Parameters
TModel
Parameters
item
TModel
The object which represents the data row to remove.
TModel
is the type of a model class that matches with the current DataObject
.
Returns
System.Boolean
True
if the row is removed successfully.
False
if no row is removed.
Remarks
The Remove
method will call the OnRowDeleting
method before removing the row, and then call the OnRowDeleted
method after removing the row.
Examples
The following code example demonstrates how to remove the data item according to the specified TModel
.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class RemoveExample
{
private readonly SchoolContext _context;
public RemoveExample(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();
// Gets the first data item of DataStore.
var department = datastore.GetModel<D_Department>(0);
Console.WriteLine("Before Remove, Rowcount: {0}", datastore.RowCount);
// Removes the data item
datastore.Remove(department);
Console.WriteLine("After Remove, Rowcount: {0}", datastore.RowCount);
/*This code produces the following output:
Before Remove, Rowcount: 4
After Remove, Rowcount: 3
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x