Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to declare the variable correctly?
Message
Information générale
Forum:
ASP.NET
Catégorie:
LINQ
Versions des environnements
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01553872
Message ID:
01553922
Vues:
59
This message has been marked as a message which has helped to the initial question of the thread.
What's wrong with the 'var' code you have? The var should work just fine and that's the proper way to declare this actually...

If you want to use the explicit type it's IQueryable< Client >.

+++ Rick ---

>Hi everybody,
>
>I am trying to write a Search method that can accept two parameters (no or Name). Here is what I've started, but I don't know how should I declare "clients" variable at the top correctly. What is it when used in LINQ query?
>
>
>public ActionResult Search(int? clientNo = null, string clientName = null)
>        {
>            
>            if (((clientNo??0) == 0) && (String.IsNullOrEmpty(clientName)==true))
>            {
>                // Assume we want to select everything
>                var clients = Db.Clients.OrderBy(c => c.Name);
>            }
>            var clients = Db.Clients.Where(c => (c.Number == clientNo)).OrderBy(c => c.Name);
>
>            return PartialView("_ClientsSearch", clients);
>        }
>
>Since I can not declare var clients twice, what will be correct solution here?
>
>Thanks in advance.
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform