DynamicModel.SetValue(string columnName, object value) Method
.NET Standard 2.x
Sets the value for the specified property (by name) in the DynamicModel
object.
Namespace: SnapObjects.Data
Assembly: SnapObjects.Data.dll
Syntax
public void SetValue(string columnName, object value)
Parameters
columnName
System.String
The name 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 according to the property name 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 Example2()
{
string sql;
sql = "select * from Course";
DynamicModel dynamicModel =
_context.SqlExecutor.SelectOne<DynamicModel>(sql);
// Gets and shows the value of the "Title" property
var value = dynamicModel.GetValue(1);
Console.WriteLine("Old Value = {0}", value);
// Sets a new value for the "Title" property
dynamicModel.SetValue("Title", "New Chemistry");
// Gets and shows the new value of the "Title" property
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