Click here to Skip to main content
15,077,494 members

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.