var user = new User()
{
Username = "a",
Password = "b",
};
user.Save();
Console.WriteLine(user.ID) // prints "504"
Console.WriteLine(user.IsLoaded()) // prints "false"
If the ID property is automatically set on Save(), I would expect IsLoaded() to also be set (to true). Why is it my responsibility to call user.SetIsLoaded(true);?
(I realize I can just edit ActiveRecord.tt to get this working, but maybe I just don’t understand what IsLoaded() actually represents.)
IsLoadedstates that the record you are looking at represents data in the database. This is for example used to detect that a record is dirty.IsLoaded == falserecords cannot get dirty because they do not represent data in the database.IsLoaded == truedoes, so changing properties on such a record sets it dirty and you can save the record again.Subsonic 3 Save() then Update()? also describes some details on this.