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

  • Home
  • SEARCH
  • 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 6868335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:25:17+00:00 2026-05-27T03:25:17+00:00

I need to update a column in a table which contains a lot of

  • 0

I need to update a column in a table which contains a lot of rows. Each row has a some large TEXT columns in it, which i do not need for my update.

I’m using LinqPAD, and this is roughly, what i wanna do:

(from s in Table
where s.FK_ID == null 
select new{s.FK_ID, s.Datum, s.PBNummer}).ToList()

.ForEach(s => s.FK_ID = new Guid(...some new guid here...));

SubmitChanges();

This does not compile, as the properties of an anonymous class type are read-only.

If I do

(from s in Table
where s.FK_ID == null 
select s).ToList()

then I can update and save, but all columns are loaded, which takes a very long time and causes memory problems.

Is there a way to only load some columns but still have an object that i can update and save using SubmitChanges? Or do i have to switch to SQL statements?

  • 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-27T03:25:18+00:00Added an answer on May 27, 2026 at 3:25 am

    Firstly, if you don’t have a primary key in the database, then you wouldn’t be able to update via Linq-To-Sql. If you have a primary key, but just don’t know which it is, you can find it in Linqpad by doing something like

    var table =  (from t in Mapping.GetTables() 
                  where t.TableName == "[Table]" select t).SingleOrDefault();
    
    (from dm in table.RowType.DataMembers 
               where dm.DbType != null && dm.IsPrimaryKey 
               select dm.Name)
              .Dump("Primary Key");
    

    Once you know the primary key, you can do something like the following, (I’m assuming the primary key is called Id)

    var oldList = (from s in Table
              where s.FK_ID == null 
              select new{s.Id , s.FK_ID, s.Datum, s.PBNummer}).ToList() ;
    

    This is similar to your query, except I have added the primary key

    foreach(var r in oldList)
    {
        Table t = new Table();
        t.Id        = r.Id ;
    
        Table.Attach(t);
        t.FK_ID   = new Guid(...some new guid here...));
    }
    SubmitChanges();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a notes column which contains text and has an id within the
I have a table named Books which contains some columns. ColumnNames: BookId, BookName, BookDesc,
I have a table which need new column. The newly introduced column need some
I need to update the comments field in a table for a large list
I have a varchar column which contains date in following format dd/mm/yyyy I need
I have a SQL table with column which contain string like 'type|type1|type2|type3|type4'. I need
I have a table which has the below columns. Ticket_id (Primary key, Int) Attachment1
I need to update a field (which is currently empty) based on a match
I have a table T (structure below) which initially contains all-NULL values in an
So I have this SQL table that I need to update. Now we use

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.