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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:18:39+00:00 2026-06-12T02:18:39+00:00

I have the following columns in my table Id (int) Name (nvarchar) usually <

  • 0

I have the following columns in my table

  • Id (int)
  • Name (nvarchar) usually < 100 characters
  • Data (nvarchar) average 1MB

I’m writing a program that will go through each row and perform some operations to the Name field. Since I’m only using the Name field and the Data field is very large, is it possible to direct EF to only load the Id and Name field?

  • 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-12T02:18:41+00:00Added an answer on June 12, 2026 at 2:18 am

    Sure is

    ctx.YourDbSet.Select(p=> new { Id = p.Id, Name = p.Name});
    

    this method is selecting into an anonymous class.

    if you want to save this back again you can do this with something which I call a dummy entity:

    foreach(var thing in ctx.YourDbSet.Select(p=> new { Id = p.Id, Name = p.Name}))
    {
        var dummy = new YourEntity{Id = thing.Id};
        ctx.YourDbSet.Attach(dummy);
        dummy.Name = thing.Name + "_";
    }
    ctx.SaveChanges();
    

    This method works with snapshot tracking as EF only tracks changes made after the attach call to send back in the update statement. This means your query will only contain an update for the name property on that entity (ie it wont touch data)

    NOTE: you want to make sure you do this on a context you tightly control as you cant attach an object which is already attached to the EF tracking graph. In the above case the select will not attach entities to the graph as its anonymous (so you are safe using the same context)

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

Sidebar

Related Questions

I have following table Managers (simplified): ID, int Name, nvarchar(100) In a stored procedure
I have a database table with the following columns: idCompany:INT, Data:LONGBLOB, Extension:VARCHAR(5), Name:VARCHAR(45). I
I have a table with the following columns: id - INT UNSIGNED AUTO_INCREMENT name
I have a table with following columns: ContractorId ......... INT ............. IDENTITY ContractorName ........
I have a table that contains the following columns: ID int, DISTANCE float, EVENT
I have a table [Users] with the following columns: INT SmallDateTime Bit Bit [UserId],
I have a table called tblRentalRates with the following columns: rate_id (int) rate_startdate (datetime)
I have a table of users containing the following columns: | User_ID (int) |
I have a (mysql) database table with the following columns: NAME | String (Unique)
I have created table #temp with columns id as int identity(1,1) and name as

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.