This is a little off the CSLA topic, but in my current project we're using CSLA objects and then implementing a web service that maps DTO's for both input parameters and output objects.
We have an Order Status property and and Order Item Status property. These are stored in the database as integers and in teh objects we have an Enum so the users can set the properties like so...
Order.OrderStatus_ID = OrderStatus.BackOrdered; (which would store a 4 in my database)
However, in a web service, how exactly do I communicate this to the consumer? I can't pass an Enum in a simple value object DTO. Is it something I just have to give them in some sort of documentation? I suppose I can just pass the text to them instead of the integer when they getOrders, but when they are editing existing orders they need to know what each integer stands for?
Web services don't define semantic meaning, only syntactic standardization. In other words, the consumer of a service doesn't automatically know how to interpret the results - they just know the proper structure of the messages necessary to make the call and receive the result.
This is, imo, one of hte weaknesses of the whole model. It doesn't really work unless you also provide human-readable documentation so someone can understand the semantic meaning of your information...
That's a long-winded way of saying that you can do whatever you want, as long as you document it. Use numeric values - they are universal. And if you want, expose a second service that returns human-readable text for the numeric values - thus simulating the enum concept as part of your overall contract.
Or just expose the numeric values and provide a web page for the consumer of your service to read what each value means. That's arguably just as good.
I think i'm going to use integers and just create another method called getOrderStatusList that will return a list of the text values and integers that go with them. With some documentation as well.
But i agree, if I have to explain it with documentation then something seems a little off.
Copyright (c) Marimer LLC