Tony Testa posted on January 27, 2008 18:36

Updated 01/29/2008

Why Another SubSonic Introduction Blog Posting?:

In my ever growing quest for programming godliness, I've feel that its important to equip myself with all the tools that I can to get the job done.  SubSonic is one of those ORM tools that can help save me/you A LOT of initial setup time when it comes to the DAL of the application.  3 tools come to mind when I think of DAL, NHibernate, SubSonic, and LINQ.  I've tried NHibernate and frankly I wasn't impressed.  I've read about LINQ but haven't had a chance to experiment with it.  SubSonic was next on my list of "tools" to experiment with.

 

Intro/History:

Roughly a year ago a co-worker of mine (Dani Diaz) and I both stumbled upon SubSonic.  We had recently been using just CodeSmith and Object/Collection template to generate our DAL for our app's.  This was certainly fine and worked for our immediate needs but it was merely an attempt at creating a solid DAL.  It worked off of SProcs generated by the CodeSmith templates.  Any database change required a rebuild of both the object classes and the sprocs.  Nothing out of the ordinary there, pretty much any DAL, generator, etc. requires some manual effort when the DB changes.  At the time, since what we had been using worked fine, I overlooked SubSonic and what it had to offer.  Now that I have had an extra year or so under my belt, and also played with some other ORM's, I've come to realize that SubSonic wasn't something to be overlooked. 

In case you're not aware of what SubSonic is, according to the website, SubSonic is a "A Super High-fidelity Batman Utility Belt. SubSonic works up your DAL for you, throws in some much-needed utility functions, and generally speeds along your dev cycle".  It is certainly a hefty claim, but after using it and messing around, a claim that I think is WELL backed up. 

I'm aware that there are quite a few SubSonic introductions/tutorials out there on the web, just do a Google search and you'll find quite a few.  After using NHibernate on a current client project, I figured it was time to give SubSonic another shot.  I frankly wasn't too happy with the setup/configuration of NHibernate or the complexity of using in our project and hoped that SubSonic was easier to use.  I'll leave my conclusion till the end.

 

What is required/need to download:

As of time of this posting, SubSonic is at version 2.0.3, you can download it here.

In my sample/example code, I used the AdventureWorksLT database.  The full AdventureWorks database is rather large so they offer a "Limited" version which is much smaller and has enough to make decent samples out of.  The AdventureWorks database is now on CodePlex and can be found here, download the "LT" version for your specific architecture. 

The examples (can be downloaded from the bottom of this posting) are built using Visual Studio 2005 SP1. 

Install both SubSonic and the AdventureWorksLT database before continuing.

 

What is SubSonic?

Like the website says, "SubSonic works up your DAL for you".  SubSonic can be used basically 2 ways, as a straight up ORM tool, or as a "zero code" ORM tool. 

If your going to use it as a straight up ORM tool, you can use SubSonic to generate objects for you based off your database.  You can do this by using the bundle tool called "SubCommander".  SubCommander interrogates your database and generates objects off of the tables.  What you end up with is basically 2 classes per table.  The first is a basic object which represents your table structure.  The second object is a "collection" object which represents the "rows" in your database table (a collection of objects).  SubCommander is a command line tool, no fancy GUI here.  I won't go into all that SubCommander can do, but just open a command line window and goto the "SubCommander" directory.  Then type "sonic /?" and look through the list of commands at your disposal.

The second way to use SubSonic is to use it as a "BuildProvider" resulting in a "zero code" DAL.  This is a web app only feature, so I haven't messed around with it too much.  I encourage you to watch Rob Connery's screencast demonstrating this and how easy it is.  Since I work with both web and desktop applications, I personally want to play with the code and move it into separate projects, so this isn't a feature I personally use.

In addition to handling the "manual labor" of the DAL, SubSonic also comes with a few pre-built user controls to help speed development. 

SubSonic comes building with the following user controls (I describe the basics, check the SubSonic documentation for more options/details):

  • AutoScaffold
    • The point here is to mimic the Ruby On Rails "scaffolding" concept where your up and running with your basic CRUD operations on a table with basically zero coding.  Then the point is to "take down" the scaffolding once you've built the finished product.  All you need to do is tell it the table or "object" to act on.
  • QuickTable
    • The ASP.NET GridView is simple to use, but carries with it some serious overhead.  The SubSonic QuickTable was designed to give you exactly that, a quick table of your data but without the overhead that the GridView has.  Simply tell the QuickTable which table or "object" to display. 
  • DropDownList
    • In almost all data-driven applications you need to add a selection control that displays a list of items, usually for "lookup" purposes.  Once again, SubSonic gives you a simple control that takes care of the grunt work, and lets you focus on your applications business logic.  The DropDownList control lets you specify the TableName and optionally the text and value fields and the beauty is that you don't have to write an "behind the scenes" code to load the dropdown and sort its values.
  • ManyManyList
    • This control aides in creating a checkbox list of items for display.  This helps in the case where you have Products and Categories where a Product can have many categories, and categories can belong to many products.  I didn't get into using this control so I won't elaborate too much on it, check the documentation for more info.

 

Project Setup

Updated 01/29/2008

I setup the project pretty simply but broken out enough to represent a more tiered approach.

image

As you can see I broke out the project into 2 separate projects.  One is the "persistence" layer, which houses our objects and collections which I generated using SubCommander.  The other project is our front-end UI project which has a few examples using SubSonic calling on the Persistence project.  I broke the projects out hoping to separate the layers, but unfortunately I wasn't able to do so fully with SubSonic.  Even though the UI project should ONLY reference the Persistence project, I still had to add a reference to the SubSonic dll (Update: This is because the persistence layer is a class library and the only way to read from a "config" file is through the executing application(in this case the Web App project), hence why I had to add the SubSonic setup info into the Web.Config).  This is because the web.config contains sections which SubSonic needs to run.  (As a side note, I've had to do the same thing with NHibernate)

In a web application we put all our "setup" information into the web.config (in a desktop app, this would be put into the app.config).  Below is an example of my web.config file.

<!-- BEGIN SUBSONIC CONFIGURATION SECTIONS -->
 
<!-- configSections isn't a "subsonic" specific section, but the "<section>" definition is -->
<configSections> 
<section name="SubSonicService" type="SubSonic.SubSonicSection, SubSonic" requirePermission="false"/>
</configSections>
 
<SubSonicService defaultProvider="Default">
<providers>
  <!-- Referencing a connection string setup in the connectionStrings section -->
  <!-- Also Supports MySQL, Oracle, SQL2000, SQL2005, SQLCE, SQLLite at the time of writing -->
  <add name="Default" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="advWorks" generatedNamespace="Persistence"/>
</providers>
</SubSonicService>
<!-- END SUBSONIC CONFIGURATION SECTIONS -->
 
<connectionStrings>
<add name="advWorks" connectionString="Data Source=coreduo;Initial Catalog=AdventureWorksLT;User ID=sa;Password=password"/>
</connectionStrings>
.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }

There are 3 things needed to setup SubSonic.

1) In the <configSections> element, tell the web.config how to read the SubSonic section.

2) Instruct SubSonic how to operate.  Tell SubSonic which DataProvider to use and which connection string to use for that provider.

3) Add a connection string.

 

Enough is enough, lets see some code!

Basic GridView List

To follow along here be sure to download the code samples.  I've already generated the DAL and put it into a separate project from the UI.

The first example is just your basic table dump of data in a GridView control, "List.aspx".  On the page, I load the ProductCollection and bind it to my GridView and set the GridView to auto generate columns. 

protected void Page_Load(object sender, EventArgs e)
{
    //load up all the products from our table and bind it to our datagrid.  could also use the SubSonic QuickTable
    //and avoid the "manual labor" of loading the table ourselves.  Check out the "ProductQuickTable.aspx" example
 
    ProductCollection products = new ProductCollection().Load();
 
    productGridView.AutoGenerateColumns = true;
    productGridView.DataSource = products;
    productGridView.DataBind();
}
.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }

There isn't anything too fancy going on here,  I get a collection of Products and then bind them to the GridView.

image

 

Basic GridView List With Where Clause

In this example I build upon the previous example by adding a dropdown of Product Categories and allow the user to view all the products of a selected category.

protected void Page_Load(object sender, EventArgs e)
{
    //add event handler so that when the user selects a different dropdown item the event fires
    categoriesDropDown.SelectedIndexChanged += new EventHandler(categoriesDropDown_SelectedIndexChanged);
}
 
public void categoriesDropDown_SelectedIndexChanged(object sender, EventArgs e)
{
    if (!string.IsNullOrEmpty(categoriesDropDown.SelectedValue))
    {
        //get all the products that match the selected product category.
        ProductCollection products = new ProductCollection().Where("ProductCategoryID", categoriesDropDown.SelectedValue).Load();
 
        productsGridView.AutoGenerateColumns = true;
        productsGridView.DataSource = products;
        productsGridView.DataBind();
    }
    else
    {
        //user selected an invalid item, so clear out the datagrid
 
        productsGridView.DataSource = null;
        productsGridView.DataBind();
    }
}
.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }

This time when the user select a category from the dropdown I pass that ProductCategoryID value in our Where clause to filter our data and then bind the returned Product Collection to the GridView.  Much like NHibernate, you filter and query your collections by specify "expressions".  With SubSonic you can do Where, Order By's, Between's, etc., the same "expressions" you'd use if you were writing SQL.

image

 

Add A Product

As with displaying data, adding data is just as easy with SubSonic.  Since objects are generated for you, you can instantiate an object, set its required fields and then persist the data to the database.

image

image

image

As you can see in the image, I've created a few textbox's and dropdowns to make a simple add product page with only the required fields.  Here is the code that gets executed on the Save button click event.

protected void saveProductButton_Click(object sender, EventArgs e)
{
    try
    {
        //create a new product and set the "necessary" fields based on the users input to the screen.
 
        Product productToAdd = new Product();
        productToAdd.Name = nameTextBox.Text;
        productToAdd.ProductNumber = productNumberTextBox.Text;
        productToAdd.StandardCost = Convert.ToDecimal(stdCostTextBox.Text);
        productToAdd.ListPrice = Convert.ToDecimal(listPriceTextBox.Text);
        productToAdd.ProductCategoryID = Convert.ToInt32(prodCategoriesDropDown.SelectedValue);
        productToAdd.ProductModelID = Convert.ToInt32(prodModelDropDown.SelectedValue);
        productToAdd.SellStartDate = DateTime.Parse(sellStartDateTextBox.Text);
        productToAdd.Rowguid = Guid.NewGuid();
        productToAdd.ModifiedDate = DateTime.Now;
 
        //persist our new proudct
        productToAdd.Save();
 
        //pull up our new product and display it in the grid for user verification
        ProductCollection products = new ProductCollection().Where("ProductID", productToAdd.ProductID).Load();
        productsGridView.AutoGenerateColumns = true;
        productsGridView.DataSource = products;
        productsGridView.DataBind();
    }
    catch (Exception ex)
    {
        //display any errors here
    }
}

Once we create the Product object and set the required fields, we persist the object and then pull it up and bind it to our GridView so that the user knows the object was successfully added.

 

Delete A Product

Again, deleting a object with SubSonic is easy.  Tell SubSonic which object based on the ID value, and SubSonic takes care of the rest.  This example has a GridView that I add a Delete command button do and then handle the row deleting event to delete the object.

image

protected void Page_Load(object sender, EventArgs e)
{
    productsGridView.RowDeleting += new GridViewDeleteEventHandler(productsGridView_RowDeleting);
 
    if (!IsPostBack)
    {
        //if we're not a postback, load our datagrid with a delete "command", and load up all the products
 
        productsGridView.AutoGenerateDeleteButton = true;
        productsGridView.AutoGenerateColumns = true;
        productsGridView.DataSource = LoadProducts();
        productsGridView.DataKeyNames = new string[] { "ProductID" };
        productsGridView.DataBind();
 
    }
}
 
public void productsGridView_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
    //get the product id of the selected row
    int productID = Convert.ToInt32(((GridView)sender).DataKeys[e.RowIndex]["ProductID"]);
 
    //delete the selected product
    Product.Delete(productID);
 
    //rebind the updated data to the grid
    productsGridView.DataSource = LoadProducts();
    productsGridView.DataBind();
}
 
//get back a list of ALL products
private ProductCollection LoadProducts()
{
    //return back a listing of all the products in our table
    return new ProductCollection().Load();
}
.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }

All we need to do to delete the Product from the database is pass the Product ID to the Delete method of our Product Object class, simple as that.  Once again SubSonic does the heavy lifting for me.

 

Update A Product

Seeing a reoccurring theme here?  SubSonic makes your CRUD tasks easy and painless.  In the update example, I added the same textbox's and dropdowns as I did for the Add Product example.  I also have a GridView on the page which I added a hyperlink column so that when it's clicked we pass a query string variable to the page and change it into "edit" mode.  Once updated we display the specific Product in the GridView.

image

image

image

protected void Page_Load(object sender, EventArgs e)
{
    //set the ProductID property to the request variable ID
    ProductID = Request["id"];
 
    if (!IsPostBack && ProductID == null)
    {
        //if we're NOT a postback and no ID was specified, then load EVERY thing from the product table and allow user to select
        //which one they want to edit.
 
        //add a link so that we can post to ourselves, but with an ID of a record to update
        HyperLinkField grdLink = new HyperLinkField();
        grdLink.Text = "Update";
        grdLink.DataNavigateUrlFields = new string[] { "ProductID" };
        grdLink.DataNavigateUrlFormatString = "UpdateProduct.aspx?id={0}";
        productsGridView.Columns.Add(grdLink);
 
        productsGridView.AutoGenerateColumns = true;
        productsGridView.DataSource = LoadProducts(null);   //load all the products
        productsGridView.DataBind();
    }
    else if (!IsPostBack && ProductID != null)
    {
        //if we're NOT a postback, but the ID variable isn't null, then load the record matching that ID for update
 
        //rebind the datagrid
        productsGridView.DataSource = LoadProducts(ProductID);
        productsGridView.DataBind();
 
        //fetch the product specified by the request variable
        Product prod = Product.FetchByID(ProductID);
 
        if (prod != null)
        {
            //set the fields so that we can update the record.
            ltProductID.Text = prod.ProductID.ToString();
            nameTextBox.Text = prod.Name;
            productNumberTextBox.Text = prod.ProductNumber;
            stdCostTextBox.Text = prod.StandardCost.ToString("F");
            listPriceTextBox.Text = prod.ListPrice.ToString("F");
            sellStartDateTextBox.Text = prod.SellStartDate.ToShortDateString();
 
            //load the dropdowns, which are basically foreign key columns
            LoadCategories(prod.ProductCategoryID.ToString());
            LoadModels(prod.ProductModelID.ToString());
        }
    }
}
 
#region Load DropDowns and Products
// code omitted from posting but is in source zip
#endregion
 
protected void saveProductButton_Click(object sender, EventArgs e)
{
    try
    {
        //update our record based on the product id
        Product prodToUpdate = Product.FetchByID(ProductID);
        prodToUpdate.Name = nameTextBox.Text;
        prodToUpdate.ProductNumber = productNumberTextBox.Text;
        prodToUpdate.StandardCost = Convert.ToDecimal(stdCostTextBox.Text);
        prodToUpdate.ListPrice = Convert.ToDecimal(listPriceTextBox.Text);
        prodToUpdate.ProductCategoryID = Convert.ToInt32(prodCategoriesDropDown.SelectedValue);
        prodToUpdate.ProductModelID = Convert.ToInt32(prodModelDropDown.SelectedValue);
        prodToUpdate.SellStartDate = DateTime.Parse(sellStartDateTextBox.Text);
        prodToUpdate.ModifiedDate = DateTime.Now;
 
        //persist our updated proudct
        prodToUpdate.Save();
 
        //pull up our updated product and display it in the grid
        productsGridView.DataSource = LoadProducts(ProductID);
        productsGridView.DataBind();
    }
    catch (Exception ex)
    {
        //disply error here
    }
}
.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }

When the user hits the Save button, we fetch the product we want to update based on the Query String Product ID.  Then, we update the Product objects properties and call its Save() method to persist it to the database.  SubSonic is smart enough to know whether it needs to update or insert a record.

 

SubSonic QuickTable Example

As mentioned earlier in this post, SubSonic comes with a barebones, low-overhead Quick Table control and all you have to do is tell it the table or "object" to display.  This gets rid of the hassle of a GridView and the best part is you don't have to write a single line of "data binding" code.

image

I'd show you the code behind, but there isn't any.  Here's the html source.

<!-- use subsonic quicktable to quickly display all table data, also add a LinkToPage for edits -->
<ss:QuickTable
    id="quickTbl"         
    TableName="Product"
    PageSize="20"
    LinkToPage="UpdateProduct.aspx"
    runat="server" />
.csharpcode, .csharpcode pre{font-size: small;color: black;font-family: consolas, "Courier New", courier, monospace;background-color: #ffffff;/*white-space: pre;*/}.csharpcode pre { margin: 0em; }.csharpcode .rem { color: #008000; }.csharpcode .kwrd { color: #0000ff; }.csharpcode .str { color: #006080; }.csharpcode .op { color: #0000c0; }.csharpcode .preproc { color: #cc6633; }.csharpcode .asp { background-color: #ffff00; }.csharpcode .html { color: #800000; }.csharpcode .attr { color: #ff0000; }.csharpcode .alt {background-color: #f4f4f4;width: 100%;margin: 0em;}.csharpcode .lnum { color: #606060; }In addition to the TableName I added a LinkToPage which adds an link to the table for us which links to the page we specify.  I also added the Register directive to the Web.Conig so that I can use the SubSonic controls on any of my pages.

 

SubSonic AutoScaffold Example

I saved the best for last here.  The AutoScaffold control does basically everything I demo'd above, but with basically ZERO effort on your part.  Add the SubSonic user control to your page and that is it, you've got all your CRUD operations taken care of and you didn't have to write any code.

image

image

image

Again, no code behind to show, but here is how the html source looks.

<!-- use subsonic auto scaffold to quickly get a page for your tables CRUD (Create, Read, Update, Delete) operations -->
<ss:Scaffold 
    ID="customerScaffold"
    TableName="Customer" 
    runat="server" />

The AutoScaffold does all our work for us.  In addition, it adds paging and sorting by default to the list view.  It does everything we need to perform our CRUD operations.

 

Conclusion

Updated 01/29/2008

Everything wasn't 100% easy, I'll admit that.  I probably spent about 3 hours of banging my head getting SubSonic to work in a multiple project solution (Update: as mentioned above, this is because of the way .NET is designed, SubSonic can only read a config file from the executing application, in our case here, the Web application project, hence the web.config file needs to have the SubSonic config info).  Every tutorial and example I found, including the ones on the SubSonic site, always used SubSonic in just 1 project.  Other than that initial hurdle, SubSonic made coding a breeze.  I personally found SubSonic easier to use and setup than NHibernate, and no need for messing "mapping" files.  I didn't get a chance to play with stored procedures with SubSonic, but from everything I've read and the screencasts I watched, SubSonic handles your sprocs with easy (these guys thought of everything!).  I also didn't play around with the custom "query" code that you can write with SubSonic, again, it appears to be pretty damn easy to use.  I am looking forward to using SubSonic on a client project and see if it stands up to the real test.

 

Source Code


SubSonicTest.zip (71 kb)


Posted in: General .NET  Tags: ,

Comments


January 27. 2008 23:42
Kevin Isom
Tony,

SubSonic can make it even easier for you. The LoadFromPost method works a treat and saves a lot of tedious setting code
weblogs.asp.net/.../subsonic-loadfrompost.aspx

http://weblogs.asp.net/kevinisomhttp://weblogs.asp.net/kevinisom


January 28. 2008 07:39
Will
I've used Subsonic on a project that got sidelined awhile ago.  Recently, I started working on another project and decided to create my own classes using the same active-record pattern that Subsonic uses.  After about ten classes, I figured out I was a moron.  I ditched my dal and set up Subsonic.  Creating my own classes helped me understand some of the challenges that Subsonic overcomes, and helped me understand better how to leverage the power of Subsonic.  It truly does kick some serious ass.

http://statestreetgang.net/http://statestreetgang.net/


January 28. 2008 08:15
Tony Testa
Kevin,
I wasn't aware of that feature, but I'm certainly going to check it out.  I'll update the post when I get a chance and give a reference to your site.

Will,
Its good that you tried to "roll your own" and realized the amount of work that has already been put into SubSonic.  Frankly I did the same thing you did, and realized that there are far smarter ppl out there that have already been down this road and I might as well use their years of experience to my advantage.

http://www.tonytestasworl.com/http://www.tonytestasworl.com/


January 28. 2008 19:28
Rob Conery
VERY NICE write up! Thanks for taking the time to do this - it really helps to have this kind of thing out there for reference. Can you tell me more about what frustrated you in terms of multiple project? I know our docs aren't umm... optimal... but if I can do one thing a day - well it helps.

Shoot me an email and lemme know!

http://blog.wekeroad.com/http://blog.wekeroad.com/


January 28. 2008 21:09
pingback
Pingback from blog.cwa.me.uk

Reflective Perspective - Chris Alcock  » The Morning Brew #20

http://blog.cwa.me.uk/2008/01/29/the-morning-brew-20/http://blog.cwa.me.uk/2008/01/29/the-morning-brew-20/


United States Stuart Allen
January 29. 2008 03:41
Stuart Allen
nice job.. thanks for taking the time to help other get acquainted with SS.

no site


Dominican Republic Jean
January 29. 2008 09:51
Jean
Hi everybody im starting with subsonic i have been using doodads with mygeneration software a year a go and now im trying to implement subsonic and i have a few questions that i want to share with you and this are:

Subsonic Brings a Project to generate web pages base with the autoscaffold and im wondering if i generate all the pages with that tool what can i do when my database change, should i generate all the pages again what can i do with the code in those pages ?

I would like to let this pages a topic of disccusion.

Thanks A lot

no site


Dominican Republic Jean
January 29. 2008 09:51
Jean
Hi everybody im starting with subsonic i have been using doodads with mygeneration software a year a go and now im trying to implement subsonic and i have a few questions that i want to share with you and this are:

Subsonic Brings a Project to generate web pages base with the autoscaffold and im wondering if i generate all the pages with that tool what can i do when my database change, should i generate all the pages again what can i do with the code in those pages ?

I would like to let this pages a topic of disccusion.

Thanks A lot

no site


United States Brad Butts
January 29. 2008 10:16
Brad Butts
Thanks for the article.  The work SubSonic does is very impressive.  One question I have is that it seems that SubSonic pushes business objects and data access operations together into a single layer.  Doesn't traditional architecture advocate two separate layers--a business layer and a separate data access layer?  Is that more theory than reality these days (even the .NET dataset wizard seem to push together business objects generated from tables with their corresponding data access operations)?

no site


United Kingdom Gregor Suttie
January 29. 2008 11:22
Gregor Suttie
Yikes your using sa to connect to sql - i shant sleep tonight now.

no site


January 29. 2008 11:36
Tony Testa
Jean,

I haven't personally used doodads (its on my todo list just to at least familiarize myself with it) so I can't speak to comparing SubSonic and doodads.  SubCommand is the tool to generate the "classes" based off your database, and yes, if your DB changes, your going to have to regenerate those classes.  SubSonic is written in a way though using "partial" classes so that you can create your own classes and add onto the functionality of an existing class.  If you use the "partial" class approach, you can then safely regenerate your classes without worrying about overwriting any functionality you may have added.



Brad,

For the sake of my examples I left the project as just two "layers".  I certainly could have added a biz layer to the project, and then inside the biz layer, enforced some extra rules for example....When I save a Product, the list price can't be less than the standard cost.  So my biz object would have a save method, which calls the SubSonic save method, but before I call the SubSonic save method, I enforce our biz logic (list price can't be less than std cost).  
I do sort of agree with you that it appears that it pushes the DAL and the BIZ layers together a bit, but it is up to you to write the BIZ layer.

http://tonytestasworld.com/http://tonytestasworld.com/


January 31. 2008 21:35
pingback
Pingback from sfonet.free.fr

SubSonic 2.0.3, un DAL orienté .NET

http://sfonet.free.fr/?p=6http://sfonet.free.fr/?p=6


February 4. 2008 08:13
pingback
Pingback from code-inside.de

Wöchentliche Rundablage: ASP.NET, ASP.NET MVC, System.AddIn, Silverlight, LINQ, C# 3.0, WPF, XBAP… | Code-Inside Blog

http://code-inside.de/blog/2008/02/04/wchentliche-rundablage-aspnet-aspnet-mvc-systemaddin-silverlight-linq-c-30-wpf-xbap/http://code-inside.de/blog/2008/02/04/wchentliche-rundablage-aspnet-aspnet-mvc-systemaddin-silverlight-linq-c-30-wpf-xbap/


Liechtenstein Bernhard Lauber
February 12. 2008 09:03
Bernhard Lauber
Very good tutorial. Thank you very much.

I have a question: When I use the QuickTable with a view instead of a table, then I get a problem if I call the the LinkToPage-aspx. The ID in the request is empty! If I use a table everything works fine. What can I do? Is there a workaround to get the ID from the page with the QuickTable to the linked page? Thanks in advance.


no site


Singapore Kiri Kamal
February 20. 2008 22:53
Kiri Kamal
Hi,

Nice article. Gud Intro for Subsonic. Currently I'm using Net-tiers. I'll check this subsonic soon.

no site


Liechtenstein Bernhard Lauber
February 22. 2008 07:55
Bernhard Lauber
The answer of my question concerning QuickTable is here: forums.subsonicproject.com/forums/p/1861/11489.aspx#11489

no site


United Kingdom JS
April 29. 2008 02:24
JS
I noticed your namespace is 'Persistence' but you dont use that in your code examples? How do you access the products classes? I'm having difficulty accessing my generated classes, and intellisense doesn't even see my namespace? Any ideas

no site


Malaysia cheing
June 11. 2008 16:26
cheing
very nice topic. Thanks for share.

no site


Malaysia cheing
June 11. 2008 17:58
cheing
may i know how to use subsonic to retrieve 1 field from database;
i want based on the "Id" to take out the "min price" .
may i know how the syntax for this requirement?

no site


August 23. 2008 23:53
Lieven Cardoen
Tony,

This tutorial was very usefull to me! I don't seem to find many tutorials that are clear... I do have one question left. What is the controller doing in SubSonic and what is it purpose?

thx, Lieven Cardoen

http://blog.johlero.eu/http://blog.johlero.eu/


September 11. 2008 01:55
bladiebla
ok

http://bla.nl/http://bla.nl/


January 16. 2009 18:56
Busby SEO Test
this blog was so nice and great
thanks for the interesting information

http://pinayspeak.com/pinaytest/http://pinayspeak.com/pinaytest/


January 26. 2009 20:28
SEO Services
very good programming skills make this tutorial worth to read.

http://myside2u.com/bloghttp://myside2u.com/blog


January 28. 2009 17:45
pingback
Pingback from devio.wordpress.com

First Steps with SubSonic « devioblog

http://devio.wordpress.com/2009/01/29/first-steps-with-subsonic/http://devio.wordpress.com/2009/01/29/first-steps-with-subsonic/


February 15. 2009 20:45
Free Registry Repair Software
The content of this post was nice and really great.
Thank you for sharing it.

http://www.registry2aid.com/Free-Registry-Scan.htmlhttp://www.registry2aid.com/Free-Registry-Scan.html


February 23. 2009 02:32
learning selling
wow you're an expert right there!

http://learningselling.blogspot.com/http://learningselling.blogspot.com/


March 17. 2009 16:59
Cash Gifting TV
great info., this is a complete resource to gather., thanks man., You're the MAN.

http://www.cashgiftingtv.com/http://www.cashgiftingtv.com/


March 19. 2009 23:20
giving4prosperity
Thanks for this great information, this will be great.Smile

http://www.givingforprosperity.com/http://www.givingforprosperity.com/


March 24. 2009 20:18
tnomeralc web design toys
Very information articles about the programming.. I really love programming too.

http://www.camalaniugan.com/tnomeralc-web-design-toys/http://www.camalaniugan.com/tnomeralc-web-design-toys/


April 15. 2009 22:02
cash4trends
Thanks for sharing the information, this helps.

http://www.thecashflowopportunity.com/http://www.thecashflowopportunity.com/


April 15. 2009 22:18
goodpeoplegives
This one is great, thanks for the share.

http://www.goodpeoplegive.com/http://www.goodpeoplegive.com/


April 15. 2009 22:27
billrainier
Continue good post.Smile

http://www.thepeoplesprogram123.com/http://www.thepeoplesprogram123.com/


April 28. 2009 15:23
Tnomeralc Web Design Toys
I love this post. Really amazing programming stuffs!

I want my post: caviteniofilipino.blogspot.com/.../...gn-toys.html to have the same stuff.

http://caviteniofilipino.blogspot.com/2009/02/tnomeralc-web-design-toys.htmlhttp://caviteniofilipino.blogspot.com/2009/02/tnomeralc-web-design-toys.html


May 8. 2009 10:09
sulumits retsambew
what a great blog, i really like it.

http://phreakaholic.com/sulumits-retsambew/http://phreakaholic.com/sulumits-retsambew/


May 15. 2009 20:03
Eriuqs Spires Healthy Recreation
Pretty good explanation about the subsonic. Will wait for more of this posts.

http://caviteniofilipino.blogspot.com/2009/05/eriuqs-spires-healthy-recreation.htmlhttp://caviteniofilipino.blogspot.com/2009/05/eriuqs-spires-healthy-recreation.html


May 20. 2009 08:55
tukang nggame
thanks for sharing the info

http://newreil.com/tukang-nggame/http://newreil.com/tukang-nggame/


May 21. 2009 11:54
tukang nggame
i can learn so much from your code, thanks.

http://belajarseo.com/bebas/tukang-nggame-seo-contest.phphttp://belajarseo.com/bebas/tukang-nggame-seo-contest.php


May 29. 2009 16:41
tukang nggame
Really nice code

http://agung.isgreat.org/tukang-nggame.htmlhttp://agung.isgreat.org/tukang-nggame.html


United States EDI
May 30. 2009 00:05
EDI
I have read a bunch of subsonic intros, and this was by far the best one.

http://www.roundhousegroup.com/http://www.roundhousegroup.com/


Bolivia mafioso710
June 12. 2009 04:13
mafioso710
Hi, would you like to explain me how is the easy and simple way to change the HeaderText of the GridView control using the SubSonic Scaffolding ? Also, I would like to rename the text of every label control in the Add and Edit Form that is generated with the SubSonic Scaffold.

I got my Scaffolding Form in English idiom but I want to translate into Spanish idiom.

I use SubSonic version 2.1 (Final)

Thanks.

no site


June 13. 2009 09:43
Sulumits Retsambew
nice post, thanks

http://yehia.org/http://yehia.org/


June 16. 2009 22:28
pingback
Pingback from fixmycrediteasily.info

Tony Testa World HowTo SubSonic Introduction | fix my credit

http://fixmycrediteasily.info/story.php?id=19011http://fixmycrediteasily.info/story.php?id=19011


June 17. 2009 15:24
rusli zainal sang visioner
I like it and I think you make a good point. Thanks for taking the time to share this with us

http://newreil.com/rusli-zainal-sang-visioner/http://newreil.com/rusli-zainal-sang-visioner/


June 23. 2009 00:11
tukang nggame
thanks for your tips

http://nggametukang.blogspot.com/http://nggametukang.blogspot.com/


United States SEO
June 23. 2009 02:09
SEO
Nice post.The ASP.NET GridView is simple to use, but carries with it some serious overhead..

http://www.webmarketingexperts.com.au/http://www.webmarketingexperts.com.au/


June 26. 2009 03:22
Search engine marketing
Computing on Demand has a good article showing how to install the open-source Subsonic music streamer on a Windows Home Server. Subsonic is yet another streaming option for getting to your music collection from anywhere on the web...

http://kenistoncompany.com/http://kenistoncompany.com/


June 28. 2009 05:00
tukang nggame
Nice post, thanks…

http://tukangnggame.marsudiyanto.info/http://tukangnggame.marsudiyanto.info/


July 2. 2009 09:40
moratmarit
Thanks for u tutorial..

http://www.moratmarit.com/http://www.moratmarit.com/


July 4. 2009 08:35
Emo Clothes
The ASP.NET GridView is simple to use, but carries with it some serious overhead. http://www.emo-site.com/emo-clothes.htm

http://www.emo-site.com/emo-clothes.htmhttp://www.emo-site.com/emo-clothes.htm


July 5. 2009 16:20
club penguin
The work SubSonic does is very impressive. One question I have is that it seems that SubSonic pushes business objects and data access operations together into a single layer. Doesn't traditional architecture advocate two separate layers--a business layer and a separate data access layer?

http://www.club-penguin.org/http://www.club-penguin.org/


July 6. 2009 01:59
Helena
Hello,

At this time, I am using Net-tiers as well but I guess I have to shift to subsonic soon. Is it really worth ?


http://www.kaboodle.com/helendenverhttp://www.kaboodle.com/helendenver


July 6. 2009 03:01
Tony
[Helena]: I feel that Subsonic is a GREAT ORM, its easy to use and very powerful.  In addition its consistently being updated as well being worked on my a MS employee.  I strongly suggest just giving it a quick try yourself on a small app just to see how it fits for your needs.  There isn't a single ORM that is going to work for 100% of the people, so try it out and see if it does what you need it to do.

http://www.tonytestasworld.com/http://www.tonytestasworld.com/


July 9. 2009 05:08
Stop Dreaming Start Action
Thanks for your post, very useful and informative

http://agung.isgreat.org/stop-dreaming-start-action.htmlhttp://agung.isgreat.org/stop-dreaming-start-action.html


July 11. 2009 03:29
Sue Dental
Really awesome! Have to browsing lot of sites if I would like to find this kind of good info.

http://www.biodentalbudapest.co.uk/http://www.biodentalbudapest.co.uk/


January 17. 2010 18:04
Cash for Gold
The Subsonic intro is one of ten that I have read because we will use it for a Cash for Gold site, and most of our questions have been dealt with.

http://www.goldcashcorp.com/http://www.goldcashcorp.com/


January 17. 2010 18:05
monitor stands
where to buy Samsung 214T Monitor Stand?

http://www.colebrookbossonsaunders.com.au/http://www.colebrookbossonsaunders.com.au/


January 17. 2010 23:06
business coupon
What are the main points of the online(internet ) marketing?

http://www.couponconnections.com.au/http://www.couponconnections.com.au/


January 17. 2010 23:23
nice nfj lersey
The Subsonic intro is one of ten that I have read because we will use it for a Cash for Gold site, and most of our questions have been dealt with.

http://www.nicenfljersey.com/http://www.nicenfljersey.com/


January 18. 2010 00:47
online poker strategy
Starting to understand a bit more now... Thanks for keeping it simple!

http://www.winpokereasy.com/http://www.winpokereasy.com/


January 18. 2010 08:15
ElisabettaGk35
If make a choice to write the <a href="www.essaysprofessors.com/...r.html">custom term paper</a>, you would have to remember that this takes huge efforts! Some persons spoil their custom term paper, because they do not have writing skills! This is bitter, but the <a href="www.essaysprofessors.com/research-paper-writing.html">research paper writing</a> service can help such kind of people any time they need it.

http://www.essaysprofessors.com/http://www.essaysprofessors.com/


January 19. 2010 14:21
payday loans
Effective leadership is putting first things first. Effective management is discipline, carrying it out.

http://www.noteletrackloans.net/http://www.noteletrackloans.net/


January 20. 2010 02:16
mma pound for pound fighters
Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.

http://phreakaholic.com/info/mma-pound-for-pound/http://phreakaholic.com/info/mma-pound-for-pound/


January 20. 2010 03:06
Volunteering Abroad


very interesting Article, it makes a change to have an author that can write well and informed articles I will be checking your posts more often

http://www.projects-abroad.co.uk/http://www.projects-abroad.co.uk/


January 21. 2010 02:22
payday loans
not really sure bout that .. a question that sometimes drives me hazy: am I or are the others crazy?

http://direct-payday-cash-advance.com/http://direct-payday-cash-advance.com/


January 25. 2010 07:20
payday loans
No person will make a great business who wants to do it all himself or get all the credit.

http://cashusloans.com/http://cashusloans.com/


January 26. 2010 07:46
Acai Berry
Really interesting comments!

http://www.acaiberryfrance.fr/http://www.acaiberryfrance.fr/


February 1. 2010 02:29
term papers
Nice One!
<a href="http://www.besttermpaper.com">term papers</a>

http://www.besttermpaper.com/http://www.besttermpaper.com/


February 1. 2010 08:10
Loans in MD
Most people give up just when they're about to achieve success.

http://superpaydayloan.com/state/Marylandhttp://superpaydayloan.com/state/Maryland


February 1. 2010 18:55
SEO Services
It is really a nice post, its always great reading such posts, this post is good in regards of both knowledge as well as information. Thanks for the post.

http://www.clickresponse.net/search-engine-optimization-service.htmhttp://www.clickresponse.net/search-engine-optimization-service.htm


February 1. 2010 20:59
whiten teeth
I know that any speed lower than the speed of sound within a sound propagating medium is called subsonic. Thanks for the post.

http://www.toothwhiteningaustralia.com.au/http://www.toothwhiteningaustralia.com.au/


February 2. 2010 19:05
sikat ang pinoy

valuable information and excellent design you got here! I would like to thank you for sharing your thoughts and time into the stuff you post!! Thumbs up!

http://www.telebisyonserye.info/http://www.telebisyonserye.info/


February 3. 2010 14:48
SEO Services India
As per usual I would love to know your thoughts so drop us a line and let us know what you think.

http://www.seoservicesindia.mobi/http://www.seoservicesindia.mobi/


February 3. 2010 20:13
Second Hand Cars
Demand has a good article showing how to install the open-source Subsonic music streamer on a Windows Home Server. Subsonic is yet another streaming option for getting to your music collection from anywhere on the web...

http://www.onestopcaradvice.co.uk/http://www.onestopcaradvice.co.uk/


February 3. 2010 20:13
orange county public records
it makes a change to have an author that can write well and informed articles I will be checking your posts more often

http://record-detective.com/http://record-detective.com/


February 4. 2010 17:09
SEO Services India
As per usual I would love to know your thoughts so drop us a line and let us know what you think.

http://www.seoservicesindia.mobi/http://www.seoservicesindia.mobi/


February 4. 2010 19:51
promotional gifts
Thanks for sharing detail information about the intro as well as history of SubSonic.

http://www.dowlis.com/http://www.dowlis.com/


February 5. 2010 11:01
Mp3 Terbaru 2010
Nice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which we all need, thanks for all the enthusiasm to offer such helpful information here.

http://mp3lagu.com/http://mp3lagu.com/


February 5. 2010 19:22
student personal loans
thanks bro..i would appreciate your blog ..if you can give a guest copy here ?

http://www.badcreditguaranteedloan.com/personal-loans-for-students.htmlhttp://www.badcreditguaranteedloan.com/personal-loans-for-students.html


February 7. 2010 03:54
spinach quiche
Damn it's easy, thanks for code!

http://www.quicheblog.com/spinach-quiche-recipeshttp://www.quicheblog.com/spinach-quiche-recipes


February 7. 2010 22:41
Internet marketing
Serge Testa is an Australian yachtsman who holds the world record for the ... External links : com/ Serge Testa's web site. Category:1950 births

http://www.kenistonompany.com/http://www.kenistonompany.com/


February 8. 2010 05:30
cash advance
The optimist sees opportunity in every danger; the pessimist sees danger in every opportunity.

http://cashusloans.com/http://cashusloans.com/


February 9. 2010 02:56
pay day loans
The true worth of a man is to be measured by the objects he pursues.

http://fastloansus.com/http://fastloansus.com/


February 9. 2010 15:01
most popular filipino
blogengine extension is great specially the new extension with new functions

http://www.telebisyonserye.info/http://www.telebisyonserye.info/


February 9. 2010 22:11
Search engine optimization
World refers primarily to the planet Earth. World may also refer to: Conceptual : World (adjective), meaning phenomena that span the globe

http://www.kenistonompany.com/http://www.kenistonompany.com/


February 10. 2010 20:57
Conference folders
This technique helps to better organize the application, many developers shy away from creating them.

http://www.dowlis.com/shop/clio_zip_conference_folderhttp://www.dowlis.com/shop/clio_zip_conference_folder


February 12. 2010 14:25
Gemma27
If some students stuck with term papers creating, thence I will recommend to buy written essays from some <a href="http://quality-papers.com">essay writing</a> service in such situation.

http://www.quality-papers.com/http://www.quality-papers.com/


February 14. 2010 01:26
Propane deep fryer
Thank you for you informative post

http://propanedeepfryer.net/http://propanedeepfryer.net/


February 14. 2010 12:00
mma pound for pound
Hey webmaster, good day. Totally Great work. You have gained a new fan. Please continue this awesome work and I look forward to see more of your excellent posts. Take care.

http://toppedia.com/mma-pound-for-pound/http://toppedia.com/mma-pound-for-pound/

Search Blog

Blog Roll

    OPMLDownload OPML file

    Recent Comments

    Banners

    Theme Grabber
    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2010 Tony Testa's World