Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to declare the variable correctly?
Message
From
29/09/2012 04:15:20
 
General information
Forum:
ASP.NET
Category:
LINQ
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01553872
Message ID:
01553930
Views:
59
This message has been marked as a message which has helped to the initial question of the thread.
>>You could also do this to allow both filters to work:
>>
public ActionResult Search(int? clientNo = null, string clientName = null)
>>        {
>>            // Assume we want to select everything
>>            var clients = Db.Clients; // Should set type of clients to IQueryable<Clients>
>>            
>>            if ((clientNo??0) != 0) //Number was supplied
>>              clients = clients.Where(c => (c.Number == clientNo));
>> 
>>           // If clientNo was supplied, clients is now filtered by that. If not, it still has the full list. The following will further filter it.
>>            if (!String.IsNullOrWhitespace(clientName) ) // Part of the name was supplied
>>                clients = clients.Where(c => (c.Name.Contains(clientName)));
>>
>>           // Order the filtered list
>>              clients = clients.OrderBy(c => c.Name);
>>
>>            return PartialView("_ClientsSearch", clients);
>>        }
>
>Rob,
>
>What is IsNullOrWhitespace - is it your own method?


Impossible

(1) String is a system class, and (2) It is a static call
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform