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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:36:04+00:00 2026-06-01T05:36:04+00:00

I was able to create a LINQ statement that I thought was strange and

  • 0

I was able to create a LINQ statement that I thought was strange and wanted to see if anyone else had experience with it.

I’ve simplified it to this:

var x = db.Test
    .Where(a => a.Field1 == Utils.CreateHash(Preferences.getValue(a.Field2)))
    .FirstOrDefault();

Now how does this translate to database code? Wouldn’t LINQ need to do a double query for every single row, i.e. for row a:

1) Query a.Field2
2) Return value to run Utils.CreateHash(Preferences.getValue(a.Field2))
3) Take that value from step 2 and compare it against a.Field1
4) Repeat 1-3 until I've gone through all the rows or returned a matching row

Wouldn’t this be extremely inefficient? Or is LINQ smart enough to run this in a better way? Note, I haven’t actually run this code so another possibility is a runtime error. Why wouldn’t LINQ be smart enough to detect a conflict then and not let me compile it?

  • 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-06-01T05:36:05+00:00Added an answer on June 1, 2026 at 5:36 am

    The query as is will not work since have a call to Utils.CreateHash in your lambda that you are trying to execute on the DB – in that context you cannot execute that method since there simply is no equivalent on the DB side hence the query will fail.

    In general the ability of 3rd party Linq IQuerable providers (e.g. Linq to SQL, Linq to Entities) to access in memory constructs such as methods or classes is very limited, as a rule of thumb at most accessing primitive values or collections of primitives will work.

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

Sidebar

Related Questions

Has anyone been able to create Container-Specific Master Pages for Safari or Chrome? I
I am able to create and execute a DTS package that copies tables from
I'm trying to create a LINQ to SQL class that represents the latest version
I have a need to create a LINQ query that returns results based on
Is it possible to create some Linq that generates a List containing all possible
You should be able to create a generic form: public partial class MyGenericForm<T> :
I have been able to create ASPX pages without the code behind, but I
I am able to create a UIImage from a Core Animation layer using the
I am able to create a connection to a local sqlite3 database ( Using
I am able to create alternate dictation grammars using the dictation resource kit or

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.