0
Completat

singleton vs single call

Paul Cannell fa 4 anys en Server / Execution • updated by Gandalf fa 4 anys 0
If you think back to .net remoting you'll prob need to read no further but in case you missed that "fun" time read on.

I have a recordset with X rows.
I need to perform some validation for each one to decide whether to exclude this record at this point (carrying on would result in failure)

Hypothetical 
in my recordset is a return code. I then need to decide based on this code whether to proceed. lets assume of all 10 return codes 3 will allow the process to continue the other 7 are considered failure. 
I create my service that takes in a code and then gets a list of statuscodes and the resulting action. 
I then call this service for each entry in my recordset. If that services has to goto the DB each time its going to be a perfomant dog. If however it were to cache the results (as we do in code all the time - think lookup date bank names, branch codes, post codes etc) it would make performance much better
So what Im asking for is a services that is created but doesnt get collected once its been used. Singleton vs SingleCall
If this exists plz point me in the correct direction

Answer

Answer
Completat
Hi Paul

Excellent question. 

You are correct, performance would be a dog. The best design to handle this is to create your validation workflow to accept recordsets Inputs and return recordset Outputs (rather than scalars and then putting it inside a for each).

In this way you can map the entire recordset with next to no overhead into the validation workflow, do one db call and then handle the iteration between records inside that workflow.

Answer
Completat
Hi Paul

Excellent question. 

You are correct, performance would be a dog. The best design to handle this is to create your validation workflow to accept recordsets Inputs and return recordset Outputs (rather than scalars and then putting it inside a for each).

In this way you can map the entire recordset with next to no overhead into the validation workflow, do one db call and then handle the iteration between records inside that workflow.