When the newly written Windows Service transmits data to the Web end, the data is empty or the service exception occurs.
Check the cause carefully. The original data passed contains an enumerated field. By default, the basic type of each element in the enumeration is
Int. In the database, int is used for storage. When I insert data of this enumeration type into the database table, the corresponding values cannot be found in the enum class. In the database, if this column can be empty, you may also forget to insert the value.
If the int type is null, 0 is assigned by default when it is read from the database. In my Enum definition, it is written in this way.
Enum site {[enummember] domicile = 1, [enummember] Hotel = 2, [enummember] gasstation = 3 ,}
Okay, this is the case now.
Int sitefromdatabase = 0; site = (SITE) sitefromdatabase;
If the site value is 0, it is impossible for Windows service to pass such data to the front-end. It is reasonable to change to domicile = 0 or not to write.
So
Conclusion 1: The Enum type should start from 0. When creating an enumeration, select the most reasonable default value and assign it a zero value. This means that as long as the enumeration is not explicitly assigned a value when it is created, all the enumerated values will have the default value.
Conclusion 2: any integer can be assigned to enum. For example, the code line site = (SITE) 10,
No errors are generated. However, this should not be done either, because the default convention is that enumeration variables only hold one of the enumerated values. Assigning any value to a variable of the enumeration type may lead to errors, for example, passing a value through the service.