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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:12:07+00:00 2026-05-22T03:12:07+00:00

I’m using Linq To Entities so I can Linq to my MySql database. My

  • 0

I’m using Linq To Entities so I can Linq to my MySql database. My problem is that I’ve got a table with large text fields, so I don’t want to load them unless I need them, and the L2E lazy loading model doesn’t work because (1) the MySql provider doesn’t seem to support lazy loading at all, and (2) even if it did, I don’t think it would be correct anyway.

Stripped down to illustrate the problem, I have a large table with columns:
Id, Text1, Text2, Text3

I’ll have a routine that needs to work only with Text1, and a different routine that works with Text2. Because the contents of the text fields are large, I really don’t want to select the text fields I’m not using for a given routine.

In other words, doing this would be too expensive:

Dim items = From i In db.MyTable Where [predicate]

But doing this:

Dim items = From i In db.MyTable Where [predicate] Select i.Id, i.Text1

creates an IQueryable(Of anonymous_type), instead of an IQueryable(Of MyTable), and since I need to be able to update various fields and call SaveChanges, I need MyTable objects to do this. I can’t convert the anonymous type to a new MyTable because the DataContext wouldn’t know about it and thus updates wouldn’t work.

(And it seems to me (though this may be my lack of L2E knowledge), that even if the MySql provider supported lazy loading, that would mean that I could specify lazy loading for the Text fields, but then it would make N queries to the server as I looped through N records. In other words, lazy loading seems to be for when you might but probably won’t need a big data column, not for when you know you want that column, but you don’t want the other columns.)

So the question is: how can I select only the fields I want while still getting an object of the right type so that I can update it later?

  • 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-22T03:12:08+00:00Added an answer on May 22, 2026 at 3:12 am

    I never really solved the problem as stated, but I’ve since found some reasonable workarounds, so I thought I’d mention them in case anyone else runs into this.

    The first is simply to factor the large text fields into their own table in the database, and then have a separate entity for that table. This happened to make sense for my application, because I had to do it anyway, but it would be annoying to change your database structure just to make some tool happy.

    The other thing you could do is to select only the fields you want, but then project back into the table type instead of using an anonymous type, leaving out the fields you don’t want. That is, instead of this:

    Dim items = From i In db.MyTable Where [predicate] Select i.Id, i.Text1
    

    do this:

    Dim items = From i In db.MyTable Where [predicate] Select New TableObject With {.Id = i.Id, .Text1 = i.Text1}
    

    Then, if you do want to get the large text fields, ask for them explicitly in a separate query.

    This is slightly irritating in that you have to explicitly populate the fields, but it’s better than the original problem and I’m sure there’s a way to improve upon this further.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't

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.