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 6686685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:12:01+00:00 2026-05-26T05:12:01+00:00

string personName= JoHn; //(in my table iam already having a person named=’john’) Func<Person, bool>

  • 0
string personName= "JoHn";  
//(in my table iam already having a person named='john')

Func<Person, bool> predicate = (p) => p.Name== personName;

var res2 = dataContext.Persons.Any(predicate);                //returns false
var res1 = dataContext.Persons.Any(p=>p.Name== personName);   // returns true

I think with predicate its considering case of personName property while without it its just ignoring case.

Any one know why??

  • 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-26T05:12:02+00:00Added an answer on May 26, 2026 at 5:12 am

    A Func<Page, bool> is a delegate, which means you are running this in LINQ-to-Objects (i.e. in memory, in C#). .NET strings are case sensitive, so this will apply case.

    This version, however:

    var res1 = dataContext.Persons.Any(p=>p.Name== personName); 
    

    is using IQueryable<T> and expression-trees; it will be executed as a TSQL filter, which will apply database rules. What happens here depends on how your DB is configured (it could be either case-sensitive or case-insensitive, depending on the database).

    If you want them both to use the same logic, then note the difference here:

    Expression<Func<Page, bool>> predicate = (p) => p.Name== personName;
    var res2 = dataContext.Persons.Any(predicate);
    

    The addition of Expression<...> makes this an expression-tree, not a delegate, so it is “composed” and executed at the database (via TSQL translation), exactly the same as:

    var res1 = dataContext.Persons.Any(p=>p.Name== personName);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you define the following: class Person(name: String, age: Int) { def toXml =
Given the classes: public class Person { public string Name { get; set; }
Given the following code: var people = new List<person>(){ new person { Name =
edited: <people> <person> <name>John Doe</name> <age>21</age> </person> <person> <name>Jane Smith</name> <age>24</age> </person> </people> actualy
class Person { public string name; public void SetName(string name) { name = name;
Imagine the following XML document: <root> <person_data> <person> <name>John</name> <age>35</age> </person> <person> <name>Jim</name> <age>50</age>
Like: Employee: Person name: String id: int + employeeCount(): int { --------------- return employeecount
I have a custom class: public class Person { public String Name { get;
string[] filesOfType1 = GetFileList1(); string[] filesOfType2 = GetFileList2(); var cookieMap = new Dictionary<string, CookieContainer>();
string x; foreach(var item in collection) { x += item+,; } can I write

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.