none
Three tier Design, Dataset and the provider model desing pattern RRS feed

  • Question

  • Hi All,

    I would like to build a three tier application in which the DAL layer is based on the provider model design patter, and the BLL will be coded to an abstarct layer interface.

    As an example in the DAL I would have

    IProductsProvider class
    ICategoriesProvider class

    the BLL will be coded against the IproductsProvider and ICategoriesProvider.

    An actual implementation of the IProductsProvider could be SQLProductsProvider.

    How is it possible to implement a similar pattern with strongly-type datasets?

    As an example I would like to define a kind of strongly-typed datatabe and tableadapters o dataset...

    IProductsTableAdapter
    IProductTable
    ICategoriesTableAdapter
    ICategoriesTable

    Code the BLL versus these interfaces, and then have

    SQLProductsTableAdapter implements IProductsTableAdapter
    SQLProductsTable  implements IProductsTable

    this is to allow the switch of difference provider without having to rewrite the BLL code.

    Thanks

    Wednesday, July 29, 2009 5:29 PM

Answers

  • Well the way that I am suggesting would require you to hand code the Adapter layer, you could not use the RAD tools for generating that.

    Do you really need to multi store capability? Perhaps you should just build it on Sql Express from the start.

    Thanks
    Chris Robinson
    Program Manager - DataSet
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 31, 2009 12:28 AM

All replies

  • Is this for a completely new application? What are the requirements for the .net Framework? Do you have 3.5 SP1 installed?

    If this is a new project, I'm not sure I would use DataSet. I would look at Ado.net Data Services
    http://msdn.microsoft.com/en-us/data/bb931106.aspx

    And Entity Framework
    http://msdn.microsoft.com/en-us/library/aa697427(VS.80).aspx

    Ado.net Data Services gives a very flexible mid tier api that can be used to build application on.

    As for your specific patterns you outline, I wouldn't use this pattern exactly. If I were to implement a pattern like this and not use the technologies above, I would do something more like this.

    Create a specific dataLayer using the DataSet desginers for the tables and relationships. These classes then produced the TypedDataTables like you have discussed above. I don't think an interface is required here.

    Then for the adapters I would create a base abstract Table adapter for each table and have virtual methods that need to be implemented. I would then add all of the operations you need to do Update, Create, Delete, Query methods on each of their base classes. Then implement these methods as provider specific logic. Essentially this is following the the adapter pattern.

    Let me know your thoughts.

    Thanks
    Chris

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Wednesday, July 29, 2009 6:45 PM
  • Hi Chris,

    This is a new project I am goin to start to develop in MS Web Developer Express 2008.

    At the moment the database I am using is based on MS Access, but in the future I would like to move it in MS SQL Server, this is why I wanted to have a the chance to switch the DB provider.

    I though of using Dataset and Table because of their RAD capabilities, and for the moment I'd rather skip to learn of how the other two technologies you suggested (Entities and Data Services) work. I am quite new to the .NET platform.

    Your second solution looks like what I want to do, hower I need to ask you two question

    1) If I use the RAD tool to develop a strongly typed DataSet using MS Access as source, how will I be able to reuse this data set when I will switch to SQL Express (Assuming that the underlying table structure will stay the same)

    2) Do you suggest to build my own TableAdapter?

    Thanks

    Pierpaolo

    Thursday, July 30, 2009 8:32 AM
  • Hi Chris,

    After a bit of work I managed to have the tableAdapter to implement a particular interface. you can find the code below.
    This way I can code the BLL to the ICategoryTblAdapter interface.
    I am still left with 2 issue to go ahead with the project and hope you can help

    1) the GetProva(int CategoryID) return a Northwind.CategoriesDataTable.
        How do I make sure that each that different TableAdapter (SQL, ACCESS) can provide the exact table schema requested by Northwind.CategoriesDataTable?

    2) How Can I remove the definition of the TableAdapter from the DataSet and move them in a different container?

    Many thanks

    Pierpaolo


    namespace

     

    NorthwindTableAdapters

    {

     

    public interface ICategoryTblAdapter {

     

    Northwind.CategoriesDataTable GetProva(int CategoryID);

     

    string Name { get; set; }

    }

     

    public partial class CategoriesTableAdapter : ICategoryTblAdapter

    {

     

    public string Name { get; set; }

     

     

     

    }

     

    }

    Thursday, July 30, 2009 11:41 AM
  • Well the way that I am suggesting would require you to hand code the Adapter layer, you could not use the RAD tools for generating that.

    Do you really need to multi store capability? Perhaps you should just build it on Sql Express from the start.

    Thanks
    Chris Robinson
    Program Manager - DataSet
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 31, 2009 12:28 AM
  • Well what you have to do is use the appropriate DataAdapter, I think for access you would use the ODBC one. As part of adapters you would have to map the data you are getting to the DataTable itself. Take a look at the this link for more information

    http://msdn.microsoft.com/en-us/library/ks92fwwh.aspx

    Thanks
    Chris Robinson
    Program Manager - DataSet
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Friday, July 31, 2009 12:31 AM