public class RegisterViewModel{
public RegisterViewModel()
{
MaxDepartmentLevel = db.Settings.Find(1).MaxDepartmentLevel;
}
private ApplicationDbContext db = new ApplicationDbContext();
public int MaxDepartmentLevel { get; set; }
}
Is this safe? Can it guarantee that db will be initialized before the line
MaxDepartmentLevel = db.Settings.Find(1).MaxDepartmentLevel; run?
In other words, what's the execution order of a class with field initialization and constructor?