15,748,559 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View Javascript questions
View C++ questions
View Python questions
View Java questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Hypermommy (Top 2 by date)
Hypermommy
17-Jan-12 12:59pm
View
Thanks everyone!
Hypermommy
17-Jan-12 11:33am
View
Okay... so I've got this function that is currently written like this:
switch (searchFacilitator_.GroupType)
{
case BRGroupTypeIds.Audit:
rowCount = mapper.ResultByRowcountForGroupSearch(searchFacilitator_.SetId,
GroupSearchBatchStrings.AUDIT_TEMPSPACE_NAME,
(DataAccessContext) dac_.Clone());
return rowCount;
break;
case BRGroupTypeIds.BusAcctMaster:
rowCount = mapper.ResultByRowcountForGroupSearch(searchFacilitator_.SetId,
GroupSearchBatchStrings.BUSACCTMASTER_TEMPSPACE_NAME,
(DataAccessContext) dac_.Clone());
return rowCount;
break;
case BRGroupTypeIds.Lic:
rowCount = mapper.ResultByRowcountForGroupSearch(searchFacilitator_.SetId,
GroupSearchBatchStrings.LIC_TEMPSPACE_NAME,
(DataAccessContext) dac_.Clone());
return rowCount;
break;
case BRGroupTypeIds.LicBill:
rowCount = mapper.ResultByRowcountForGroupSearch(searchFacilitator_.SetId,
GroupSearchBatchStrings.LICBILL_TEMPSPACE_NAME,
(DataAccessContext) dac_.Clone());
return rowCount;
break;
case BRGroupTypeIds.TTA:
rowCount = mapper.ResultByRowcountForGroupSearch(searchFacilitator_.SetId,
GroupSearchBatchStrings.TTA_TEMPSPACE_NAME,
(DataAccessContext) dac_.Clone());
return rowCount;
break;
case BRGroupTypeIds.TTR:
rowCount = mapper.ResultByRowcountForGroupSearch(searchFacilitator_.SetId,
GroupSearchBatchStrings.TTR_TEMPSPACE_NAME,
(DataAccessContext) dac_.Clone());
return rowCount;
break;
case BRGroupTypeIds.TTRBill:
rowCount = mapper.ResultByRowcountForGroupSearch(searchFacilitator_.SetId,
GroupSearchBatchStrings.TTRBILL_TEMPSPACE_NAME,
(DataAccessContext) dac_.Clone());
return rowCount;
break;
default:
return 0;
}
This feeds into a dynamically build SQL statement.
But I could write it like this:
foreach (int TempspaceName in GroupSearchBatchStrings)
{
if (TempspaceName = searchFacilitator_.GroupType)
{
mapper.ResultByRowcountForGroupSearch((searchFacilitator_.SetId, TempspaceName, dac))
}
}
Of course, I'd have to modify some of what's going on downstream to handle the fact that we're sending in an integer, not a string, but I could do that.
So, basically, I'm trying to figure out which is generally more effective, a switch or a loop.