Right now I query without the conditional part but the web server must loop through millions of returned records to do the calculation where I would prefer the SQL server to perform this on the first call.
Expand|Select|Wrap|Line Numbers
- var EDsAndCounts = db.Electors.
- Where(x => x.VotedStrikeList == true
- || x.VotedPollBook == true).
- Select(x => x).ToList();
Here is one of the sql statement I need to convert.
Thank you in advance for any input /info on the matter.
P:oD
Expand|Select|Wrap|Line Numbers
- SELECT elector.ed_code,
- Sum(CASE
- WHEN votedstrikelist = 1 THEN 1
- ELSE 0
- END) AS VotedStrikeListCount,
- Sum(CASE
- WHEN votedpollbook = 1 THEN 1
- ELSE 0
- END) AS VotedPollBookCount,
- Sum(CASE
- WHEN votedpollbook = 1
- OR votedstrikelist = 1 THEN 1
- ELSE 0
- END) AS TotalCount
- FROM elector
- WHERE ( votedstrikelist = 1 )
- OR ( votedpollbook = 1 )
- GROUP BY elector.ed_code