Salva,
You probably meant [FlagsAttribute].
Unfortunately it will not work - enum values will be preserved in the proxy
class but the enum values will be 2 power n (2, 4, 8, 16,...) . I need the
values match my database id...
[FlagsAttribute]
public enum Color
{
Red = 20,
Black = 13
}
Will give me Red = 2, Black = 4
[quoted text, click to view] "Salvador" <Salvador@discussions.microsoft.com> wrote in message
news:3A0F0F19-3DF8-4A97-8704-2189DE09D11F@microsoft.com...
> Hi,
>
> I found the same issue, so a way to solve it is specifying that is a flag
> enum, use the following attribute
>
> [Flags()]
> public enum YourEnum
>
> All your values will be respected,
>
> hope this helps
> Salva
>
>
> "Stan" wrote:
>
> > 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?
> >
> > Thanks,
> >
> > -Stan
> >
> >
> >