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. WPF
  4. WCF How to specify max and min value for a data member? [modified]

WCF How to specify max and min value for a data member? [modified]

Scheduled Pinned Locked Moved WPF
csharpcsswcftutorialquestion
6 Posts 4 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.
  • C Offline
    C Offline
    cateyes99
    wrote on last edited by
    #1

    Say, if I have a data member which is string, I want to specify that its length need to be between 6 to 9 characters, or a data member is positive integer which needs to be less than 1000. Are there any attributes I can apply to data members to do this rather than validate this sort in the code? Thanks.

    L P B 3 Replies Last reply
    0
    • C cateyes99

      Say, if I have a data member which is string, I want to specify that its length need to be between 6 to 9 characters, or a data member is positive integer which needs to be less than 1000. Are there any attributes I can apply to data members to do this rather than validate this sort in the code? Thanks.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      I think you need to validate the business object.

      Cheers, Karl » CodeProject 2008 MVP, CodeProject 2009 MVP My Blog | Mole's Home Page | XAML Power Toys Home Page

      Just a grain of sand on the worlds beaches.

      1 Reply Last reply
      0
      • C cateyes99

        Say, if I have a data member which is string, I want to specify that its length need to be between 6 to 9 characters, or a data member is positive integer which needs to be less than 1000. Are there any attributes I can apply to data members to do this rather than validate this sort in the code? Thanks.

        P Offline
        P Offline
        Pete OHanlon
        wrote on last edited by
        #3

        Karl's exactly right. You wouldn't apply the rules on the data member because this is just a contract - it's not a business rule, because your rules may change, but your contract should remain the same. I would also add a check in your client code as well.

        "WPF has many lovers. It's a veritable porn star!" - Josh Smith

        As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

        My blog | My articles | MoXAML PowerToys | Onyx

        C 1 Reply Last reply
        0
        • C cateyes99

          Say, if I have a data member which is string, I want to specify that its length need to be between 6 to 9 characters, or a data member is positive integer which needs to be less than 1000. Are there any attributes I can apply to data members to do this rather than validate this sort in the code? Thanks.

          B Offline
          B Offline
          BrowniePoints
          wrote on last edited by
          #4

          As of right now there is no native Attribute-based method of doing this. However, it is not difficult to create your own framework and set of attributes to encapsulate this behavior. Soon (well more like next year), Microsoft will be releasing the RIA services framework for Silverlight. It includes an attribute based method of providing validation. Eventually, it will be made available for WPF. If you have a more pressing need, this is something I've been looking into and could be convinced to accelerate my process on it. I've been a bit stagnant lately and need to get my finger on the keys (outside of work). Let's connect and I can get information on what you would need a validation framework to do and how you'd like to use it.

          C 1 Reply Last reply
          0
          • P Pete OHanlon

            Karl's exactly right. You wouldn't apply the rules on the data member because this is just a contract - it's not a business rule, because your rules may change, but your contract should remain the same. I would also add a check in your client code as well.

            "WPF has many lovers. It's a veritable porn star!" - Josh Smith

            As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.

            My blog | My articles | MoXAML PowerToys | Onyx

            C Offline
            C Offline
            cateyes99
            wrote on last edited by
            #5

            I think it's still useful if it's able to specify some constraints on data contracts, the reasons are the same as it in XSD. Besides, when publish those data contracts, WCF still makes use of XSD, right?

            1 Reply Last reply
            0
            • B BrowniePoints

              As of right now there is no native Attribute-based method of doing this. However, it is not difficult to create your own framework and set of attributes to encapsulate this behavior. Soon (well more like next year), Microsoft will be releasing the RIA services framework for Silverlight. It includes an attribute based method of providing validation. Eventually, it will be made available for WPF. If you have a more pressing need, this is something I've been looking into and could be convinced to accelerate my process on it. I've been a bit stagnant lately and need to get my finger on the keys (outside of work). Let's connect and I can get information on what you would need a validation framework to do and how you'd like to use it.

              C Offline
              C Offline
              cateyes99
              wrote on last edited by
              #6

              That's be great, thanks very much. My email

              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