Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3721974
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T05:44:23+00:00 2026-05-19T05:44:23+00:00

Hello question on like condition using lambda expression. I hope you can reply to

  • 0

Hello question on like condition using lambda expression.

I hope you can reply to this post asap (Its little urgent)

My question is how to do like queries , i understand i can use startswith , contains etc or sqlmethods like . But how to use them in lambda expression.

For eg : Person entity contains name , in the below example, I search for person.name =’john’.

But the user may select any operator at run time for comparision (like , equals, starts with , ends with etc)
Eg. it could be person.name =’john’ or person.name like ‘j%’ or person.name like ‘%j’ or person.name contains ‘%jo%’

how can I construct dyanmic query . can you please modify the code above and let me know. As I am quite new to linq , I dont understand lambda so well.

Your help is appreciated.

Source code –

  DataContext context = new DataContext // linq to sql data context.
  Query<Person> q = new Query<Person>(context);
  Expression<Func<Manufacturer, bool>> expn = DynamicExpression.ParseLambda<Manufacturer, bool>(condition, value); //condition is "name=@0",   value = string[] i.e - "john"
                q.Where = expn;
                return q.SingleOrDefault<Person>();

eg of expn is name =@0 , but i want to do name like ‘%@0%’ how ?

Query class is as follows

public Expression<Func<T, bool>> Where
{
    set { m_where = value; }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T05:44:24+00:00Added an answer on May 19, 2026 at 5:44 am

    In Linq2SQL, you can use SqlMethods.Like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello can anybody solve this please I'm creating the object in the action class
I asked a question like this in an interview for a entry level programmer:
Hello guys I think the question i asked in the previous post is unclear
Hello again ladies and gents! OK, following on from my other question on ASP.NET
Hello I was writing a Regular Expression (first time in my life I might
Hello I am working with a simulator that uses rcS scripts to boot, this
Original Question Hello All, I'm a bit confused on how MVC maps HTTP requests
Question Hello All, I've had some confusion for quite some time with essentially flooring
Hello everybody. I would like to know how to download and save a file
Rals 3.0 My question is using link_to_remote to make an ajax call. 2.3.8 Ajax

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.