IDataPacker.AddRaw(string key, string value) Method
.NET Standard 2.x
Add a raw text string as an element to the IDataPacker
object.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
void AddRaw(string key, string value);
Parameters
key
System.String
The key for the element, which is the identifier of the element in the IDataPacker
object.
value
System.String
The raw text string, which is the value of the element to be added to the IDataPacker
object.
Examples
The following code example adds a raw text string as an element to the IDataPacker
object and uses "RawValue" as the key name for this element.
using SnapObjects.Data;
using System;
using System.Collections.Generic;
using System.Data;
namespace Appeon.ApiDoc.IDataPackerExamples
{
public class AddRawExample
{
private readonly SchoolContext _context;
public AddRawExample(SchoolContext dataContext)
{
// Sets the data context.
_context = dataContext;
}
public void Example()
{
var packer = new DataPacker();
// Adds a raw text string to the current IDataPacker
packer.AddRaw("RawValue", "CourseID:1001;Title:Chiness;");
// Gets and shows the number of elements of IDataPacker
Console.WriteLine("The element count: {0}", packer.Count.ToString());
// Gets and shows the data values in JSON format
Console.WriteLine(packer.GetTextString(DataFormat.Json));
/* This code example produces the following output:
The element count: 1
{"RawValue":CourseID:1001;Title:Chiness;}
*/
}
}
}
Applies to
.NET Standard
2.x