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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T16:18:30+00:00 2026-05-28T16:18:30+00:00

I am having some performance issue of linq compiled query. using (var txn =

  • 0

I am having some performance issue of linq compiled query.

using (var txn = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted }))
        {
            DateTime dealcheck = new DateTime(1753, 2, 2);

            Func<DealDataClassesDataContext, string, IQueryable<DealsDetails>> DD =
            CompiledQuery.Compile<DealDataClassesDataContext, string, IQueryable<DealsDetails>>

    ((DealDataClassesDataContext nw, string sCity) =>

        from D in nw.Deals

        where D.Address == City && (D.DealTime >= DateTime.Now || D.DealTime == dealcheck) && PriceMax >= D.DealPrice && D.DealPrice >= PriceMin && DisCountMax >= D.SavingsRate && D.SavingsRate >= DiscountMin && (D.DealTime >= DateTime.Now.AddDays(TimeMin) && D.DealTime <= DateTime.Now.AddDays(TimeMax) || D.DealTime == dealcheck)

        select new DealsDetails(
                          lst,
                          D.DealId,
                          D.DealHeadline,
                          D.DealCategory,
                          D.BuyPrice,
                          D.DealPrice,
                          D.SavingsRate,
                          D.SavingAmount,
                          D.RelatedWebsite,
                          D.Address,
                          string.Empty,
                          D.DealImage,
                          string.Empty,
                          string.Empty,
                          D.Time, D.CurrentTime, D.DealTime,
                         D.Location, string.Empty, string.Empty, D.Latitude, D.Longitude, D.Islocal, D.VendorMail, D.MerchantInfo, D.Review, D.HowItWork, D.DealUrl
                          ));

            string jString = "";

            //int a = q(DealDbContext1, "London").Count();

            using (DealDataClassesDataContext db = new DealDataClassesDataContext())
            {
                IQueryable<DealsDetails> DDD = DD.Invoke(DealDbContext, "London");

                if (lstSite.Count > 0 && lstSite[0] != "AllDeals")
                {
                    DDD = DDD.Where(D => D.RelatedWebsite.Split(',').Where(x => lstSite.Contains(x)).Any()); //.Where(row => row.Category.ToList().Where(x => lst.Contains(x)).Any()).ToList();
                }
                if (lst.Count > 0)
                {
                    DDD = DDD.Where(D => D.Categories.Split(',').Where(x => lst.Contains(x)).Any()); //.Where(row => row.Category.ToList().Where(x => lst.Contains(x)).Any()).ToList();
                }
                if (sortby == "Time" && orderby == "Asc")
                {
                    DDD = (from d in DDD orderby d.Time ascending select d).Skip((Page - 1) * PageSize).Take(PageSize);
                }
                else if (sortby == "Time" && orderby == "Desc")
                {
                    DDD = (from d in DDD orderby d.Time descending select d).Skip((Page - 1) * PageSize).Take(PageSize);
                }
                else if (sortby == "Price" && orderby == "Asc")
                {
                    DDD = (from d in DDD orderby d.DealPrice ascending select d).Skip((Page - 1) * PageSize).Take(PageSize);
                }
                else if (sortby == "Price" && orderby == "Desc")
                {
                    DDD = (from d in DDD orderby d.DealPrice descending select d).Skip((Page - 1) * PageSize).Take(PageSize);
                }
                else if (sortby == "Percent" && orderby == "Asc")
                {
                    DDD = (from d in DDD orderby d.SavingsRate ascending select d).Skip((Page - 1) * PageSize).Take(PageSize);
                }
                else if (sortby == "Percent" && orderby == "Desc")
                {
                    DDD = (from d in DDD orderby d.SavingsRate descending select d).Skip((Page - 1) * PageSize).Take(PageSize);
                }
                else
                {
                    DDD = DDD.Skip((Page - 1) * PageSize).Take(PageSize);
                }

                string Currency = "$";
                foreach (DealsDetails item in DDD)
                {
                    //Creating Html String Here
                }

                return jString;

I have attached My whole code here please check what is the issue with this it’s taking too long time to respond arround 20 sec.

Mainly the foreach loop takng more then 17 sec.

Please let me know how do I compile this query.

Thanks in Advance.

  • 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-28T16:18:30+00:00Added an answer on May 28, 2026 at 4:18 pm

    In addition to pre-compiling your query, you should pre-generate the local query views

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

Sidebar

Related Questions

I'm testing a Google Web Toolkit application and having some performance issue with multiple
I am having noticing some performance issues on my MySQL Server. The slow query
I'm having some performance issue on my embedded device: # uptime 14:59:39 up 5:37,
We are having some performance issues with a page and I wanted to ask
I am having some performance problems with my Delphi 2006 app. Can you Suggest
Basically having some trouble with using Hover to hide or show an item. The
I'm having a performance issue with a select statement I'm executing. Here it is:
I'm having a performance issue when deploying an app developed on 10g XE in
I'm having some performance issues while developing Android apks. My machine is an AMD
I'm having a WinForms performance issue that might be related to the fact that

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.