Let's say I have the following ActiveRecord class:
[ActiveRecord]
public class Account
{
...
[BelongsTo("CustomerId")]
public Customer Customer { get; set; }
}
Currently, in order to set the value of the CustomerId field, I have to get the entire Customer object from the database and assign it to my account:
Customer customer = Customer.FindById(1);
account.Customer = customer;
It is not very effective. I would prefer to set the value of the CustomerId field directly without rounding the database, for example.
account.CustomerId = 1;
What is the right way to do this?
source
share