473,698 Members | 2,379 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Querying using Linq

I want to allow users to search last names, using wildcards.

When I try to following in my web app:

//employees data was previously retrieved and stored in ViewState.
var filteredData = from p in employees.ToArr ay() select p;
filteredData = from c in employees
where SqlMethods.Like (c.Username, "%" + txtSearchCriter ia.Text +
"%")
select c;

I get the following error:
Method Boolean Like cannot be used on the client it is only for translation
to SQL

Is there a way I can use Linq to get what I want and stay client side?
Nov 19 '08 #1
3 3003
use standard c# string functions:

filteredData = from c in employees
where c.Username.ToUp per().IndexOf(t xtSearchCriteri a.Text.ToUpper) >= 0

you could easily implement a Like string extension that did this and have:

filteredData = from c in employees
where c.Username.Like (txtSearchCrite ria.Text)
-- bruce (sqlwork.com)
"Mike Collins" wrote:
I want to allow users to search last names, using wildcards.

When I try to following in my web app:

//employees data was previously retrieved and stored in ViewState.
var filteredData = from p in employees.ToArr ay() select p;
filteredData = from c in employees
where SqlMethods.Like (c.Username, "%" + txtSearchCriter ia.Text +
"%")
select c;

I get the following error:
Method Boolean Like cannot be used on the client it is only for translation
to SQL

Is there a way I can use Linq to get what I want and stay client side?
Nov 19 '08 #2
Doh! Leave to me to forget about IndexOf :) Thanks.

"bruce barker" wrote:
use standard c# string functions:

filteredData = from c in employees
where c.Username.ToUp per().IndexOf(t xtSearchCriteri a.Text.ToUpper) >= 0

you could easily implement a Like string extension that did this and have:

filteredData = from c in employees
where c.Username.Like (txtSearchCrite ria.Text)
-- bruce (sqlwork.com)
"Mike Collins" wrote:
I want to allow users to search last names, using wildcards.

When I try to following in my web app:

//employees data was previously retrieved and stored in ViewState.
var filteredData = from p in employees.ToArr ay() select p;
filteredData = from c in employees
where SqlMethods.Like (c.Username, "%" + txtSearchCriter ia.Text +
"%")
select c;

I get the following error:
Method Boolean Like cannot be used on the client it is only for translation
to SQL

Is there a way I can use Linq to get what I want and stay client side?
Nov 19 '08 #3

"Mike Collins" <Mi*********@di scussions.micro soft.comwrote in message
news:1E******** *************** ***********@mic rosoft.com...
>I want to allow users to search last names, using wildcards.

When I try to following in my web app:

//employees data was previously retrieved and stored in ViewState.
var filteredData = from p in employees.ToArr ay() select p;
filteredData = from c in employees
where SqlMethods.Like (c.Username, "%" + txtSearchCriter ia.Text +
"%")
select c;

I get the following error:
Method Boolean Like cannot be used on the client it is only for
translation
to SQL

Is there a way I can use Linq to get what I want and stay client side?

Use .contains/startswith/endswith on the field to get a 'LIKE' equivalent

LS

Nov 19 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2650
by: Greg | last post by:
I am working on a project that will have about 500,000 records in an XML document. This document will need to be queried with XPath, and records will need to be updated. I was thinking about splitting up the XML into several XML documents (perhaps 50,000 per document) to be more efficient but this will make things a lot more complex because the searching needs to go accross all 500,000 records. Can anyone point me to some best practices...
5
2370
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to make up the finished part. The sub-parts can also be made up of sub-parts and those sub-parts can also be made up of sub-parts etc etc. All parts are contained within the same table and I have a seperate table
0
1358
by: ranganadh | last post by:
Dear Group members, I am new to LINQ, pls help on the deeling with huge amount of data with the C# stand Alone application. I have two file, which contains more then 2 lacs lines in every file suppose file1 like ...
3
8377
by: Marc S | last post by:
var qry = from s in dbCxt.Services from j in s.Jobs where s.ID == 200 select new { s, j }; I want to call qry.ToList() but with the list containing anonomyous types I don't know how to create a List object to support that. I want to get all records in a List so that I only have to make 1 call to the database. Is this even possible?
2
1478
by: Steven Cheng [MSFT] | last post by:
Hi Cj, I also noticed that the "Act" variable here seems hasn't been declared(or declared anywhere else?). I've try building the same code and got the same result and the "Operator '+' cannot be applied to operands of type 'string' " error does pointing to the "Act.Trim" which should be of method call syntax such as Act.Trim() After change it, that error is eliminated.
0
846
by: cj2 | last post by:
Thank you! cfps.Christian wrote:
0
891
by: Sean MC | last post by:
hi Alexandre, Marc Could you please show a few lines of sample code for us on how to query xml data column within Linq. thanks a lot! Sean
2
1731
by: Neil Chambers | last post by:
All, I have a class describing various actions to take against a LINQ to SQL datasource. What are the pros/cons of instantiating the LINQ object either in the root of the class (for lack of a better description) or within each of the methods? I am naturally drawn to instantiating the LINQ object in the root but some examples I've seen preffer to keep this local to the methods. Is there a compelling reason for this? It seems that garbage...
7
11580
by: shapper | last post by:
Hello, Is it possible to multiply all Prices in a List<Productby 1.1 using Linq? Product has a property named Price. Thanks, Miguel
0
8675
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9029
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.