Hi all,
I have a base class with the following (trimmed for brevity) declaration:
public abstract class MyBaseClass
{
public int RecordId { get; private set; }
public string ObjectName { get; set; }
public abstract string Status { get; set; }
public GetMyObject(int id)
{
MyObject myObject = context.GetObjectById(id);
this.RecordId = myObject.RecordId;
this.ObjectName = myObject.ObjectName;
this.Status = myObject.Status
}
}
Which is used by the following class:
public class MySpecificClass : MyBaseClass
{
public override string Status
{
get
{
if(this.Status == "something")
return "some status";
else
return "some other status";
}
set
{
this.Status = value;
}
}
public GetMySpecificObject(int id) : base(id)
{
}
}
Now when I bind my specific object to my model (my implementation happens to be MVC) the object is returned just fine if I only access the RecordID and the ObjectName, but I get a stackoverflow exception if the get or set accessors to my (overridden) Status is hit.
I found a similiar question on SO already...
... but going by the auto-property implementation, my code looks like it would be correct and not create an infinate loop (but this does appear to be the case). Any ideas on how I would correctly override that property?
Thanks!