Exception: MissingSetterException
Posted by Gerhard Stephan on April 17th, 2008
The MissingSetterException will be thrown if a value object shall be loaded that has a property without a setter.
/// <summary>
/// This is an uncomplete value object that throws a missing setter exception
/// </summary>
public class MissingSetter : ValueObject
{
private string missing = string.Empty;
public string Missing
{
get { return missing; }
}
}
The following test will throw the MissingSetterException when trying to load the object.
[Test]
[ExpectedException(typeof(MissingSetterException))]
public void TestMissingSetterException()
{
MissingSetter missingSetter = new MissingSetter();
using (AdFactum.Data.ObjectMapper mapper = OBM.CreateMapper(Connection))
{
// First save
bool nested = OBM.BeginTransaction(mapper);
mapper.Save(missingSetter);
OBM.Commit(mapper, nested);
// The Load throws the MissingSetterException, because the value can’t be set to the object.
ObjectDumper.Write(mapper.Load(typeof (MissingSetter), missingSetter.Id));
}
}
