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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:54:16+00:00 2026-06-16T19:54:16+00:00

I have one Linq Query. When I run the query, Only for 10 records

  • 0

I have one Linq Query. When I run the query, Only for 10 records its taking 13 seconds to extract the data to the model. I need to know the query which I wrote is good for performance or not. Please guide me what i am doing wrong.

Code

    var stocktakelist = (from a in Db.Stocktakes
                             select new ExportStock
                                 {
                                     Id = a.Id,
                                     ItemNo = a.ItemNo,
                                     AdminId = (from admin in Db.AdminAccounts where admin.Id == a.Id select admin.Name).FirstOrDefault(),
                                     CreatedOn = a.CreatedOn,
                                     Status = (from items in Db.Items where items.ItemNo == a.ItemNo select items.ItemStatu.Description).FirstOrDefault(),
                                     Title = (from tit in Db.BibContents where tit.BibId == (from bibs in Db.Items where bibs.ItemNo == a.ItemNo select bibs.BibId).FirstOrDefault() && tit.TagNo == "245" && tit.Sfld == "a" select tit.Value).FirstOrDefault()   // This line of Query only makes the performance Issue
                                 }
            ).ToList();

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-16T19:54:19+00:00Added an answer on June 16, 2026 at 7:54 pm

    I was trying to create the corresponding query with some joins for practice.
    I cannot test it and i’m not 100% sure that this query will you get the result
    you are hoping for but maybe at least it will give you a hint on how to write
    joins with linq.

    from a in Db.Stocktakes
    
    join admin in Db.AdminAccounts
      on a.Id equals admin.Id
    into adminJoinData
    from adminJoinRecord in adminJoinData.DefaultIfEmpty( )
    
    join items in Db.Items
      on a.ItemNo equals items.ItemNo
    into itemsJoinData
    from itemsJoinRecord in itemsJoinData.DefaultIfEmpty( )
    
    join title in Db.BibContents
       (
           from subQuery in Db.BibContents
           where subQuery.TagNo == "245"
           where subQuery.Sfld == "a"
           select subquery
       )
      on title.BibId equals itemsJoinRecord.BidId
    into titleJoinData
    from titleJoinRecord in titleJoinData.DefaultIfEmpty( )
    
    select new ExportStock( )
    {
        Id = a.Id,
        ItemNo = a.ItemNo,
        AdminId = adminJoinRecord.Name,
        CreatedOn = a.CreatedOn,
        Status = itemsJoinRecord.ImemStatu.Description,
        Title = titleJoinRecord.Value
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one LINQ Query. I dont know much about LINQ. I was working
So I write a Linq query and it takes 16 seconds to run. Decide
I have one Linq to SQL query that simply joins three tables and then
Is it possible to convert this code into one LINQ query. I could have
I have a requirement to create a linq query that selects data from a
I have two LINQ statements that I would like to make into one, but
I have been using Linq to SQL for a while now on one of
I have a LINQ to SQL class VoucherRecord based on a simple table. One
I have an XML file that I'm trying to parse with Linq-to-XML. One of
I have one XML request which I need to modify (to XML) and then

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.