Extending Entity Data Model
-
I'm trying to understand why part of my code will not work, on a partial class from a (service) EDM object table on the clientside. So here is the code:
public partial class tblSOM\_Supplier { #region IDataErrorInfo Members public string Error { get { return ValidationHelper.GetError(SelfValidate()); } } public string this\[string columnName\] { get { var \_\_ValidationResults = SelfValidate(); if (\_\_ValidationResults == null) return string.Empty; var \_\_ColumnResults = \_\_ValidationResults.Errors.FirstOrDefault<ValidationFailure>(x => string.Compare(x.PropertyName, columnName, true) == 0); return \_\_ColumnResults != null ? \_\_ColumnResults.ErrorMessage : string.Empty; } } #endregion
}
The problem is the
public string this[string columnName]
part. It doesn't recognise any of the properties from the table tblSOM_Supplier If I add a propertypublic String ThisTestProperty { get; set; }
to this partial class then it works exactly as it should! (Showing validation error on the TextBox) How can I get the EDM properties to function correctly in this modified partial class?
-
I'm trying to understand why part of my code will not work, on a partial class from a (service) EDM object table on the clientside. So here is the code:
public partial class tblSOM\_Supplier { #region IDataErrorInfo Members public string Error { get { return ValidationHelper.GetError(SelfValidate()); } } public string this\[string columnName\] { get { var \_\_ValidationResults = SelfValidate(); if (\_\_ValidationResults == null) return string.Empty; var \_\_ColumnResults = \_\_ValidationResults.Errors.FirstOrDefault<ValidationFailure>(x => string.Compare(x.PropertyName, columnName, true) == 0); return \_\_ColumnResults != null ? \_\_ColumnResults.ErrorMessage : string.Empty; } } #endregion
}
The problem is the
public string this[string columnName]
part. It doesn't recognise any of the properties from the table tblSOM_Supplier If I add a propertypublic String ThisTestProperty { get; set; }
to this partial class then it works exactly as it should! (Showing validation error on the TextBox) How can I get the EDM properties to function correctly in this modified partial class?
I now worked this out. I just needed to add
IDataErrorInfo
to the partial class! Simple really... I now have a project that validates data entry using FluentValidation, on Entity Data Model tables, in a MVVM project using WCF services! yippie...... If I get the time, this will be my first article, me thinks :-D ;P :~