Suppose there is class with enum
public enum Color { Red = 20, Black = 13 }
And suppose there is a method
public void SetColor (int id, Color c) {
}
When web service proxy class is generated the value of the enums will be lost:
public enum Color { Red, Black }
so that essentially Red = 1 and Black = 2
That creates some problems. For example if Red = 20 and Black = 13 are database keys, it is impossible to update the database via web service, since the passing values are different.
I can see two solutions for this:
1. Manually update enum in proxy class to public enum Color { Red = 20, Black = 13 }
2. Change
public void SetColor (int id, Color c)
to
public void SetColor (int id, int c)
I don't really like either one.
Any thoughts or ideas?.....
and is same resolved in WCF ?
|
| Author: vipul 18 Aug 2008 | Member Level: Diamond | Rating: Points: 6 |
hi, you can't access the enum in your page, Here i put the example and how to use enum the aspx.cs page
in Webservice ============== public enum MailTypes { Yahoomail = 1, Hotmail = 2, Gmail = 3, AOLmail = 4, Rediffmail = 5 } [WebMethod] public string Getalladdress(MailTypes Mailtypes,string txtUserName, string txtPassword) { }
In other web site ================= Getaddress objAddress = new Getaddress(); // this is class of the web service where i declare web method strdata = objAddress.Getalladdress(MailTypes.Hotmail, txtUserName.Text.ToString(), txtPassword.Text.ToString());
vipul, http://dongavipul.blogspot.com
|
| Author: avtar 18 Aug 2008 | Member Level: Gold | Rating: Points: 3 |
In this example what will be the value of MailTypes.Hotmail ? if in enum its 20 ? it will be 2 rite...? is there a way to get exact enum value ? and is this same problem in wCF as well ?
|