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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:52:40+00:00 2026-05-10T20:52:40+00:00

my goal is to get lots of rows from a translation table. I use

  • 0

my goal is to get lots of rows from a translation table. I use an ID to get a subset of the table (say 50 rows) then I use another ID to the rows I want from this subset. Using typed datasets I do the following to get the main dataset:

funderTextsDS.tbl_funderTextsDataTable fd =  (funderTextsDS.tbl_funderTextsDataTable)(new funderTextsDSTableAdapters.tbl_funderTextsTableAdapter()).GetData(); 

Then for each value I want to get:

fd.Select('eng_code = '' + element + '' and funderID = '' + funderID + ''')[0]['funderText'].ToString(); 

Using ANTS profiler to check the code I found that this method used about 170ms over 10 page refreshes (220 calls to the fd.select…)

When I rewrote this to LINQ it took more than 2000ms to do the same work. Here is the LINQ code I used:

IrmDatabaseContext irmDB = new IrmDatabaseContext(); irmDB.tbl_funderTexts.Single(f => f.funderID == funderId && f.eng_code == element).funderText; 

Anyone have a good way of doing this with LINQ? By looking into sql server profiler i saw that the LINQ actually generated a single select for each text i retrieved. (ie LINQ= 220 selects from the db, tableadapter method = 10 selects)

Solution: After having read around the net I found that David B was on the right track, although the for loop threw me off for quite a while. Anyway, the trick as he said, is to use a list as this actually forces linq to run the query against the DB and cache it localy. http://blogs.msdn.com/wriju/archive/2007/07/17/linq-to-sql-caching-the-query-execution.aspx.

So my solution ended up like this:

List<tbl_funderText> fd = (from tf in irmDB.tbl_funderTexts                       where tf.funderID == (int)cpcrow.cpc_fundingPartnerID                       select tf).ToList(); 

Then everytime I want an element I do:

fd.Single(f => f.eng_code == element).funderText; 

Analyzing with ANTS I then found that time was reduced to 150ms (about the same as the tableAdapter. SQL query analyzer shows that the SQL is run only one time.

  • 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. 2026-05-10T20:52:41+00:00Added an answer on May 10, 2026 at 8:52 pm

    Ah, so in the TableAdapter method, you’re pulling rows into memory and then querying those in-memory rows further. That’s easy to do in LINQ.

    myDataContext dc = new myDataContext(); List<FunderText> myList = myDataContext.tbl_funderTexts.ToList();  List<string> result1 = new List<string>(); foreach(var theValue in myValues) {   result1.Add(     myList.First(f => f.funderID == theValue.funderId && f.eng_code == element).funderText   ); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer When you install Nexus, you'll end up with two directories:… May 11, 2026 at 11:32 am
  • added an answer If you imagine XY trend then Data Fields will be… May 11, 2026 at 11:32 am
  • added an answer You have to do Donut caching on the server side.… May 11, 2026 at 11:32 am

Related Questions

my goal is to get lots of rows from a translation table. I use
My goal is to maintain a web file server separately from my main ASP.NET
my goal is to write a stored proc that can collect all field values
My goal is to recognize simple gestures from accelerometers mounted on a sun spot.
My goal is to integrate testing into my development environment (as post-build step). I
My goal is to make a Button that has two Content values. Imagine a
My goal is to make the title of every external link equal to its
I am currently working on a project and my goal is to locate text
I'm working on a Silverlight Polling control. My goal is to have a Button
Given any arbitrary, one-line string, my goal is to render it into a bitmap

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.