Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trouble with casting
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01608054
Message ID:
01608078
Vues:
21
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform