I'm trying to manually build a WCF Data Service using a POCO data model and I cannot figure out how to properly expose enum
values. Assuming a simple model like:
public class Order
{
public int ID {get; set;}
public string Description {get; set;}
public OrderStatus Status {get; set;}
}
public enum OrderStatus
{
New,
InProcess,
Complete
}
How do you expose the valuable information in the OrderStatus
property via the OData WCF Data Service?
If you do nothing, the Data Service generates a runtime error (enum is invalid property). The only answer I've seen that at least resolves the error is to mark the enum
property as Ignored, such as:
[System.Data.Services.IgnoreProperties("Status")]
public class Order ...
This works, but it forces you to "omit" valuable information from the service layer.
Are there other options for working with enum values in WCF Data Services?
EDIT: Please notice this is WCF Data Services (aka Astoria). This is not raw WCF Services, in which case the answers are more clear.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…