Say I have the following AR Object:
namespace Models
{
[ActiveRecord(Lazy = true, Table = "Answer"), Serializable]
public class Answer : ActiveRecordLinqBase<Answer>
{
public Answer() {}
[PrimaryKey]
public virtual int ID { get; set; }
[BelongsTo("QuestionID")]
public virtual Question Question { get; set; }
}
}
Is there any way for me to directly set QuestionID? I tried creating an additional AR [Property] called QuestionID for this purpose, but I run into the NH error described here:
I am trying to unit test this class, and I really don't want to have to set up a database (in memory or otherwise) to do this unit testing. Setting the QuestionID is all I need to do for the functionality currently under test.
Thanks.
I found a hack that accomplishes what I need, but negatively impacts the NH cache (I think): I simply assign to a "new" Question, instantiated with the existing question's ID. It looks horrible, and, like I said, it essentially loads the cache with these (very) partially-filled question objects (not verified, but behavior seems to indicate as much).