none
DAAB - Good Pratice RRS feed

  • Question

  • Hi

    I’m rebuilding a web service to use Store Procedures e DAAB

    I use 3 layer application.

     

    1st Layer returns commands (DbCommand).

     

    public class Allocation

    {

     

    public static DbCommand SelectOrdersStanding(int workYear)

    {

    Database db = Database .CreateDatabase();

          DbCommand cmd db.GetStoredProcCommand("OrdersStandingAllocation_Get");

     

          db.AddInParameter(cmd, "@WorkYear", DbType.Int32, workYear);

     

               return cmd;

            }

    }

     

     

    2nd Layer Return Data(DataSet).

    class AllocationDB

    {

    public DataSet GetOrdersStanding(int workYear)

         {

    DataSet dataSet = new DataSet();

              Database db = ConnDBBiz2.CreateDatabase();

              DbCommand cmd = Allocation.SelectOrdersStanding(_workYear);

     

              db.LoadDataSet(Allocation.SelectOrdersStanding(_workYear),

    dataSet, "Allocation");           

     

    return dataSet;

     

        }

    }

     

     

    3th Layer (WebMethod).

    public class WsService : System.Web.Services.WebService

    {

        [WebMethod]

        public string GetOrdersStanding(int workYear)

        {

        AllocationDB all = new AllocationDB();

     

           return all.GetOrdersStanding(workYear);

       }

    }

     

     

    Can I use Static Class in 1st Layer? This a good pratice?

     

     

    Thank You

     

    Regards,

     

    Rui Figueiredo

     

    (Sorry about my English)

     

    Thursday, June 5, 2008 1:05 PM

All replies

  • Yes, you could. 

     

    I dont know if you step through the Database.CreateDatabase() function all the way.  The DAAB internally is creating the connection object in a static method.  So if you are basically worried about creating connection object every time when you call Allocation.SelectOrdersStanding(..), it is already taken care for you.

    Thursday, June 5, 2008 1:52 PM