[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

LINQ to SQL using Like operator

Posted on 2010-04-01
3
Medium Priority
?
951 Views
Last Modified: 2013-11-11
I can't make the SQL Like operator work in LINQ In ASP.NET 3.5, Visual Studio 2008 VB.net.
This code returns nothing:
       Dim returnPart = From parts In db.arm_parts Where parts.part_number Like "%1000%"

But this code works:
        Dim returnPart = From parts In db.arm_parts Where parts.part_number = "110001"

I have the Option Compare set to text at the project level and the Class level
0
Comment
Question by:foulkrj
  • 2
3 Comments
 
LVL 5

Expert Comment

by:pschrama
ID: 29368118
You can do an SQL like with Linq by using Contains():

Dim returnPart = From parts In db.arm_parts Where parts.part_number.Contains("%1000%")
0
 
LVL 5

Accepted Solution

by:
pschrama earned 2000 total points
ID: 29369064
Forgot to remove the %'s, make that: .Contains("1000")
0
 
LVL 1

Author Closing Comment

by:foulkrj
ID: 31709994
Thank you.  That was quick, easy and right on.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a wide range of advantages associated with the use of ASP.NET. This is why this programming framework is used to create excellent enterprise-class websites, technologies, and web applications.
The PowerShell Core 6.0 of .NET release is just the beginning. The upcoming PowerShell Core 6.1 would have artificial intelligence and internet of things capabilities. So many things to look forward to in the upcoming release.
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

611 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question