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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:27:35+00:00 2026-06-02T09:27:35+00:00

I want to get a single property(blob) from a single entity (by Id). I

  • 0

I want to get a single property(blob) from a single entity (by Id). I have:

context.References
    .Single(r => r.ID == id)
    .Blob;

This strikes me as inefficient, because I’m getting the entire Reference, only to discard everything except the Blob. This led to

context.References
    .Where(r => r.ID == id)
    .Select(r => r.Blob)
    .Single();

Which should only query for the Blob, but having the Single as an afterthought at the end is somewhat annoying (yet enforcing the singularity I feel is necessary). My question is this: is there a better way to accomplish this, or is my second codeblock just the way it is?

Thanks!

  • 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-02T09:27:36+00:00Added an answer on June 2, 2026 at 9:27 am

    I’m afraid that’s the way it is. Running your queries in LINQPad shows that Entity Framework translates the queries to this:

    SELECT TOP (2) 
    [Extent1].[Id] AS [Id], 
    [Extent1].[Blob] AS [Blob], 
    ... etc for all columns
    FROM [dbo].[References] AS [Extent1]
    WHERE 1 = [Extent1].[Id]
    

    and

    SELECT TOP (2) 
    [Extent1].[Blob] AS [Blob]
    FROM [dbo].[References] AS [Extent1]
    WHERE 1 = [Extent1].[Id]
    

    So you’re correct that the second query is slightly more efficient. Whether this is significant is something for you to test and decide.

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

Sidebar

Related Questions

I want to get data from two tables with single Entity class. How?? public
I want to get the single digits from two digits.for example if 36 I
Trying to do this with a single query, but want to get a list
I am trying to get a single property from a joined table where a
If we want to get a single GPS fix in Android we actually use
I want get as much as possible from Redis + Hiredis + libevent. I'm
I want to get flashvars from a string which is in the code below.
I have a control with a dependency property which I want to pass which
I have two simple POCO classes; I'm trying to get the MyY property below
I need to extract an array of a single property from a custom object

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.