I’m reviewing some sample code where a User property is defined and (as far as I can tell) is functioning correctly:
** [Required]
public string FirstName
{
get { return mFirstName; }
set { mFirstName = value; }
}
[Required]
public string LastName
{
get { return mLastName; }
set { mLastName = value; }
}
public string FullName
{
get { return FirstName + " " + LastName; }
}
**
There’s validate class running against this Entity but doesn’t include FullName:
protected override void ValidateUpdate(User entity)
{
applySimpleRules
(
entity,
x => x.FirstName,
x => x.LastName,
x => x.Phone1,
x => x.Email,
x => x.Address,
x => x.City,
x => x.State,
x => x.Zip,
x => x.Password
);
As I say, the project is saving and editing everything I test except one specific record that looks, structurally like all the rest – has a legal First and Last but this function (called by the above function) is choking and seems to be flagging ‘Full Name’ which, again… _shouldn’t be in the list of validated fields.
But I’m not clear why the code fails to include a setter and wonder if that’s coming into play.
thx
I can’t tell you why it’s failing, but it doesn’t have a setter because the property isn’t persisted. I’m assuming EntityFramework here, in which case, it needs to have a public getter/setter to be persisted. Perhaps you could include the code for
applySimpleRules?