tags:

views:

873

answers:

1

digging around subsonic, i came across this

link text

good article but have some ?'s

now i want the option to return either a IList or Dataset, would I create an abstarct factory for this, if so can I have one generic method which would take in either IList or Dataset as a ref parameter and populate the passed in object?

is it a good practice to declare static classes in the business layer which talks to my data layer so that in my UI where i have a gridviewcontrol i can do this

mybusinesslayer.getdata(ref myDataset) //as mybusinesslayer is static

mygridviewcontrol.datasource = mydataset....

+3  A: 

What are you planning to do with the Datasets that you cannot do with the ILists? IMHO, you'll want to be strongly typed as much as possible.

On my team, we connect our middle tier to ObjectDataSources and then all of our GridViews, ListViews, etc... use them to fetch data:

Business Layer / Middle Tier

namespace Project
{
    public class BusinessLayer
    {
        public IList<Product> GetProducts()
        {
            return new Select().From( Products.Schema ).Where( Products.Columns.Status ).IsEqualTo( true ).ExecuteTypedList<Product>();
        }
    }
}

On Page

<asp:ObjectDataSource id="odsProducts" runat="server" TypeName="Project.BusinessLayer" SelectMethod="GetProducts()"></asp:ObjectDataSource>

Then from there, you can connect any of your data-view controls (Gridview, Listview, etc...) to the data source. It's very clean and requires no code in the code-behind.

I also came across that article by Rob that you posted and have found it helpful in trying to figure out how to write de-coupled apps with SubSonic.

Jeffaxe
+1 for clean code!
KG