Columns Recompute
Let's review the columns collection and it's role in the Recompute
- Columns that are not added to the column collection will not participate in the recompute
BindValue will only recompute based on columns that were added before it in the Columns Collection
- Add a local column EndOfMonth
public class DemoColumnsCollection : UIControllerBase
{
public readonly Models.Orders Orders = new Models.Orders();
public readonly DateColumn EndOfMonth = new DateColumn("EndOfMonth");
public DemoColumnsCollection()
{
From = Orders;
Columns.Add(Orders.OrderID);
Columns.Add(Orders.CustomerID);
Columns.Add(Orders.OrderDate);
}
public void Run()
{
Execute();
}
protected override void OnLoad()
{
View = () => new Views.DemoColumnsCollectionView(this);
}
}
- Add a BindValue for the
EndOfMonth
column
public class DemoColumnsCollection : UIControllerBase
{
public readonly Models.Orders Orders = new Models.Orders();
public readonly DateColumn EndOfMonth = new DateColumn("EndOfMonth");
public DemoColumnsCollection()
{
From = Orders;
Columns.Add(Orders.OrderID);
Columns.Add(Orders.CustomerID);
Columns.Add(Orders.OrderDate);
Columns.Add(EndOfMonth).BindValue(() => Orders.OrderDate.EndOfMonth);
}
public void Run()
{
Execute();
}
protected override void OnLoad()
{
View = () => new Views.DemoColumnsCollectionView(this);
}
}
- Note that in the migrated code, the call to
BindValue
will be attached to theColumns.Add
call for that column - Note that if the
Columns.Add
of theEndOfMonth
column is after the call toColumns.Add
of theOrders.OrderDate
column, the value ofEndOfMonth
will automatically change whenever the value ofOrders.OrderDate
changes - Note that if the
Columns.Add
of theEndOfMonth
column is Before the call toColumns.Add
of theOrders.OrderDate
column, the value ofEndOfMonth
will NOT automatically change whenever the value ofOrders.OrderDate
changes, it'll only evaluate once when you enter the row. - We can use Alt + up arrow to move a line of code up, or Alt + down arrow to move a line of code down
Debugging
- Break into the code using the Shift + F12
- In the "Watch" window, use the
__RecomputePath
property of any column, to see the columns that when changed, will cause this column to recompute
- You can also use the 'Make Object ID' right click option, to highlight columns (or any object) in the watch window and the columns collection, using the
{$1}
symbol.
Help us improve, Edit this page on GitHub
or email us at info@fireflymigration.com