Stopping a field change being recorded as a modification to a POCO object
I am developing with silverlight, and RIA services. I have a POCO object defined on the server side like this,
public class AssessmentRoad
{
[Key]
public int Id { get; set; }
[Required]
public int RoadLength { get; set; }
public int RoadId { get; set; }
[Required]
public string RoadName { get; set; }
[Required]
public string Suburb { get; set; }
public bool HasModified { get; set; }
}
The field HasMod开发者_StackOverflow社区ified is calculated and used on the client side only.
RIA services when I call SaveChanges decides that the entities need saving because the HasModified field has changed.
Is there an attribute I can use to make sure this doesn't happen? Or do I need to use a partial class etc?
On second thoughts perhaps the HasModified field shouldn't be there at all, and this should be wrapped up in a ViewModel instead?
Add this property to a client-side partial class. See http://msdn.microsoft.com/en-us/library/ee707331(v=VS.91).aspx.
精彩评论