Solved

LINQ query time out

Posted on 2013-06-03
4
382 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 63

Accepted Solution

by:
Fernando Soto earned 500 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 63

Expert Comment

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

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

623 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