DataPacker.DataPacker() Constructor
.NET Standard 2.x
Initializes a new instance of the DataPacker
class.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public DataPacker()
Examples
The following code example creates a DataPacker
object, adds multiple elements to it, and calculates the number of elements in it.
using SnapObjects.Data;
using System;
using Appeon.ApiDoc.Models.School;
namespace Appeon.ApiDoc.DataPackerExamples
{
public class DataPackerExample
{
private readonly SchoolContext _context;
public DataPackerExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example()
{
// Creates a DataPacker object
var packer = new DataPacker();
var course = new Course()
{
CourseID = 1050,
Title = "Chemistry",
Credits = 4,
DepartmentID = 1
};
// Adds a model object.
packer.AddModel("Course", course);
// Adds a value.
packer.AddValue("Name", "Name1");
// Gets and shows the number of elements in packer
Console.WriteLine("The element count: {0}", packer.Count.ToString());
/* This code example produces the following output:
The element count: 2
*/
}
}
}
Example Refer To
Model Class: Course
Applies to
.NET Standard
2.x