IDataStore.SetDataContext(DataContext context) Method
.NET Standard 2.x
(Obsolete) SetDataContext method is deprecated, please use DataContext property instead.
Sets the data context which represents the entry point to a database.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public bool SetDataContext(DataContext context);
Parameters
context
SnapObjects.Data.DataContext
A DataContext
object which represents the entry point to a database.
Returns
System.Boolean
Returns true
if it succeeds.
Examples
The following code example demonstrates how to use the SetDataContext
method.
using DWNet.Data;
using System;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class SetDataContextExample
{
private readonly SchoolContext _context;
public SetDataContextExample(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");
// Calls SetDataContext to set the data context.
datastore.SetDataContext(_context);
// Retrieves rows from the database for datastore.
datastore.Retrieve();
Console.WriteLine("After Retrieve, Rowcount: {0}",
datastore.RowCount);
/*This code produces the following output:
After Retrieve, Rowcount: 4
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x