Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trouble with casting
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01608054
Message ID:
01608078
Views:
20
>>In the database the column is smallint and defined as short in the class definition.
>
>So why is the Convert.ToInt16 needed?

I think it's not needed, I'll remove it. In my original code it was needed as the result was anonymous type.

So, the code now is reduced to
var lastLocSuffix = _salespointAdapter.GetAll().Max(sp=>sp.LocSuffix);
            Int16 newSuffix = 1;
            if (lastLocSuffix != null)
            {
                newSuffix = lastLocSuffix++;                
            }

            salespoint.LocSuffix = newSuffix;
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform