Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Extending Entity Data Model

Extending Entity Data Model

Scheduled Pinned Locked Moved C#
helpquestion
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sevententh
    wrote on last edited by
    #1

    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 property

    public 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?

    S 1 Reply Last reply
    0
    • S Sevententh

      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 property

      public 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?

      S Offline
      S Offline
      Sevententh
      wrote on last edited by
      #2

      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 :~

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups