What is the best method to do the following? RRS feed

  • Question

  • User1888235789 posted


    I have  a class. Inside that class i have one primary method. And i have another 15 methods that i need to check before the primary method executes. The scenario is like this:








    Do something.....


    The check methods all return true or false. If all are true then the code will execute else no.

    Now I have two ways to do this.

    1) Write the primary method in wcf and check all the other methods in stored procedure. By this I need to only access the database once. The stored procedure will execute all the functions and if all are true it will return true to execute the rest.

    2) I need to write all the methods one by one, multiple stored procedures and here the control will go from wcf to db again and again.

    I am confused how to deal with this kind of situation without affecting the performance. Can you please suggest me some better idea how to do it?


    Monday, December 22, 2014 1:56 AM


  • User-484054684 posted

    It looks like you are doing some kind of validation logic. If your validation (or business logic) definitely needs data from DB to accomplish the task, then, hitting the database once and doing all the logic in Stored Procedure makes sense.

    Having multiple calls from your application to DB multiple times would result poor performance. So, I would suggest option 1 (single call to DB, all logic in SP) makes sense.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, December 22, 2014 7:51 AM