DynamicModel.SetValue(int index, object value) Method
.NET Standard 2.x
Sets the value for the specified property (by index) in the DynamicModel
object.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public void SetValue(int index, object value)
Parameters
index
System.Int32
The zero-based index of the property in the DynamicModel
object to set value.
value
System.Object
The value to set to the specified property.
Examples
The following code example sets the value for the property according to the specified index in the DynamicModel
object.
using SnapObjects.Data;
using System;
namespace Appeon.ApiDoc.DynamicModelExamples
{
public class SetValueExample
{
private readonly SchoolContext _context;
public SetValueExample(SchoolContext dataContext)
{
// Sets the data context
_context = dataContext;
}
public void Example1()
{
string sql;
sql = "select * from Course";
DynamicModel dynamicModel =
_context.SqlExecutor.SelectOne<DynamicModel>(sql);
// Gets and shows the value of the property whose index = 1
var value = dynamicModel.GetValue(1);
Console.WriteLine("Old Value = {0}", value);
// Sets a new value for the property whose index = 1
dynamicModel.SetValue(1, "New Chemistry");
// Gets and shows the new value of the property whose index = 1
value = dynamicModel.GetValue(1);
Console.WriteLine("New Value = {0}", value);
/* The code example produces the following output:
Old Value = Chemistry
New Value = New Chemistry
*/
}
}
}
Applies to
.NET Standard
2.x