I have an ASP.NET MVC solution and also a WCF service for data access. In my WebUI I have some enums like this:
public enum CompanyColumsEnumViewModel
{
CompanyName,
CompanyPostCode,
CompanyCity
}
This enum allows me to perform a search based on specific columns. For example: searching for ‘2000’ in the CompanyPostCode field.
When a user submit a search formular, I call my service and I pass several parameters like this:
var companies = _requestServiceClient.GetCompanies(term, column);
Where term = ‘2000’ and column = ‘CompanyPostCode’
My question is what is the best:
-
pass column as en enumeration in the web service? (1)
-
pass column as simple string in my web service? (2)
(1) IEnumerable< Company> GetCompanies(string term, CompanyColumsEnumViewModel column)
(2) IEnumerable< Company> GetCompanies(string term, string column)
If I work with enumerations I have to declare these enumerations on both side: one in my WebUI and one in my web service?
Thanks.
If your enum is part of your ServiceContract (as in it exists as a parameter) then you need to attribute it up as a
DataContract:Then, you can discover this in a service reference on the client side. This, I think, would be prefered to a string column.