Data Bindings
Introduction
Default Bindings
Binding to Database Objects
{
"FirstName": "",
"LastName": "",
}using Starcounter;
namespace MyApp
{
[Database]
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public string FullName => FirstName + " " + LastName;
}
class Program
{
static void Main()
{
Db.Transact(() => // Add a new Person instance to the database
{
new Person()
{
FirstName = "Steve",
LastName = "Smith"
};
});
Handle.GET("/GetPerson", () =>
{
var person = Db.SQL<Person>("SELECT P FROM Person P").First; // Retrieve a database object from the database
var json = new PersonPage()
{
Data = person // Bind the database object to the Typed JSON object
};
return json;
});
}
}
}Binding to Code-Behind Properties
Mixing Database and Code-Behind Bindings
Different Types of Bindings
Auto
Bound
Unbound
Parent
Rules When Bindings are Created
Modify Bindings
Opting Out of Bindings
Binding to Properties With Different Names
Binding to Custom Properties in Code-Behind
Binding to a Deep Property
Setting Type of Binding for Children
Specify Data Type
IBound
IExplicitBound
Last updated