IDataStore.AsEnumerable<TModel>(DwBuffer bufferType = DwBuffer.Primary) Method
.NET Standard 2.x
Converts the data in the specified buffer to an IEnumerable<TModel>
object. Defaults to the primary buffer if bufferType
is not specified.
Namespace: DWNet.Data
Assembly: DWNet.Data.dll
Syntax
public IEnumerable<TModel> AsEnumerable<TModel>(DwBuffer bufferType = DwBuffer.Primary);
Type Parameters
TModel
The type of a model
class that matches with the current DataObject
.
Parameters
bufferType
DWNet.Data.DwBuffer
The data buffer from which data will be converted to the IEnumerable<TModel>
object. The default value is DwBuffer.Primary
.
Returns
System.Collections.Generic.IEnumerable<TModel>
An IEnumerable<TModel>
object. The generic parameter TModel
must match with the DataObject
property of the DataStore.
Examples
The following code example demonstrates how to use the AsEnumerable
method to convert the data to an IEnumerable<TModel>
object.
using Appeon.ApiDoc.Models;
using DWNet.Data;
using System;
using System.Linq;
namespace Appeon.ApiDoc.IDataStoreExamples
{
public class AsEnumerableExample
{
private readonly SchoolContext _context;
public AsEnumerableExample(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("DataStore Primary Rowcount: {0}",
datastore.RowCount);
// Converts data in the primary buffer.
var departmentList = datastore.
AsEnumerable<D_Department>(DwBuffer.Primary);
Console.WriteLine("Converted Primary Rowcount: {0}",
departmentList.Count());
// Converts data in the delete buffer.
datastore.DeleteRow(0);
Console.WriteLine("DataStore Delete Rowcount: {0}",
datastore.DeletedCount);
departmentList = datastore.
AsEnumerable<D_Department>(DwBuffer.Delete);
Console.WriteLine("Converted Delete Rowcount: {0}",
departmentList.Count());
// Converts data in the filter buffer.
datastore.SetFilter("departmentid < 2");
datastore.Filter();
Console.WriteLine("DataStore Filter Rowcount: {0}",
datastore.FilteredCount);
departmentList = datastore.
AsEnumerable<D_Department>(DwBuffer.Filter);
Console.WriteLine("Converted Filter Rowcount: {0}",
departmentList.Count());
/*This code produces the following output:
DataStore Primary Rowcount: 4
Converted Primary Rowcount: 4
DataStore Delete Rowcount: 1
Converted Delete Rowcount: 1
DataStore Filter Rowcount: 3
Converted Filter Rowcount: 3
*/
}
}
}
Example Refer To
Model Class: D_Department
DataWindow File: d_department
Applies to
.NET Standard
2.x