Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

LINQ query time out

Posted on 2013-06-03
4
Medium Priority
?
387 Views
Last Modified: 2013-06-04
can any one help me and tell me why this linq query take long time ?
 _objDashBoardInfoLst = (from s in _objCashCollectionEntity.Transactions
                                    where (s.Transaction_Status == "0" || s.Transaction_Status == "1") && (s.Transaction_DateTime >= _datetimeFromdate.Date && s.Transaction_DateTime <= _datetimeTodate.Date)

                                    group s by s.Transaction_DateTime.Value.Month into grouping
                                    select new
                                    {
                                        _datetimeDate = grouping.Select(s => s.Transaction_DateTime.Value).FirstOrDefault(),
                                        _doubleTransactionsAmount = grouping.Select(s => s.Transaction_TotalValue).Sum(),
                                        _doubleTransactionsFees = grouping.Select(s => s.Transaction_TotalFees).Sum(),
                                        _intTransactionsCount = (grouping.Select(s => s.Transaction_ID).Count()),
                                        _intPostOfficesCount = (grouping.Select(s => s.FK_PostOfficeID).Distinct().Count()),
                                    }).AsEnumerable().Select(item => new DashBoardInfo
                                 {
                                     Date = item._datetimeDate,
                                     TransactionsAmount = (decimal)item._doubleTransactionsAmount,
                                     TransactionsFees = (decimal)item._doubleTransactionsFees,
                                     PostOfficesCount = item._intPostOfficesCount,
                                     TransactionsCount = item._intTransactionsCount,
                                 }).ToList();

Open in new window

any way to enhance it ?
thnx
0
Comment
Question by:AhmedHindy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39216718
Whats the size of the collection?
0
 
LVL 64

Accepted Solution

by:
Fernando Soto earned 1500 total points
ID: 39217339
Hi AhmedHindy;

Would not this bering back the same results in less time?

 _objDashBoardInfoLst = (from s in _objCashCollectionEntity.Transactions
                         where (s.Transaction_Status == "0" || s.Transaction_Status == "1") && (s.Transaction_DateTime >= _datetimeFromdate.Date && s.Transaction_DateTime <= _datetimeTodate.Date)
                         group s by s.Transaction_DateTime.Value.Month into grouping
                         select new DashBoardInfo
                         {
                             Date = grouping.Select(s => s.Transaction_DateTime.Value).FirstOrDefault(),
                             TransactionsAmount = grouping.Select(s => s.Transaction_TotalValue).Sum(),
                             TransactionsFees = grouping.Select(s => s.Transaction_TotalFees).Sum(),
                             PostOfficesCount = (grouping.Select(s => s.Transaction_ID).Count()),
                             TransactionsCount = (grouping.Select(s => s.FK_PostOfficeID).Distinct().Count()),
                         }).ToList();

Open in new window

0
 
LVL 4

Author Closing Comment

by:AhmedHindy
ID: 39218688
it worked
0
 
LVL 64

Expert Comment

by:Fernando Soto
ID: 39218837
Glad to hear that worked out for you. Have a great day.
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question