IDataStore.Dispose() Method
.NET Standard 2.x
Performs application-defined tasks associated with freeing, releasing, or resetting the unmanaged resource. Inherited from IDisposable
.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public void Dispose();
Examples
The following code example demonstrates how to use the Dispose
method to release memory.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class DisposeExample
{
private readonly SchoolContext _context;
public DisposeExample(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();
// This datastore has four records.
int count = datastore.RowCount;
Console.WriteLine("Retrieved Rowcount: {0}", count);
//Resets the unmanaged resource in the DataStore.
datastore.Dispose();
try
{
count = datastore.RowCount;
}
catch (Exception ex)
{
Console.WriteLine("The datastore is invalid.");
Console.WriteLine("Exception: {0}", ex.Message);
}
/*This code produces the following output:
Retrieved Rowcount: 4
The datastore is invalid.
Exception: Object reference not set to an instance of an object.
*/
}
}
}
Example Refer To
DataWindow File: d_department
Applies to
.NET Standard
2.x