MonoRail With SubSonic
In the Castle forums, it was asked if it is possible to use SubSonic as the DAL for a MonoRail application. The answer is absolutely yes.
You will usually see MonoRail samples with either Active Record or NHibernate, simply beacuse this is what most of the users of MonoRail are using, but MonoRail has no data access preference. (There are extention to MonoRail that make it work better with Active Record and NHibernate, but those are just that, extentions, the core is completely data layer agnostic).
So, how would you go about using SubSonic with MonoRail?
Here is the controller:
{
public void List()
{
ProductCollection products = new ProductCollection();
products.Load();
PropertyBag["products] = products;
}
}
And here is the view:
<ul>
<% for product in products: %>
<li> ${product.Name} </li>
<% end %>
</ul>
Comments
Nice!
I've been saying (for far too long now) that I really want to get down-and-dirty with both SubSonic and MonoRail - and now it sounds like I can get neck deep in both at the same time!
I've been using MonoRail with Paul Wilson's O/R mapper (www.ormapper.net) -- most recently using my own wrapper (http://www.hosted-projects.com/trac/computersims/wilsonorwrapper) -- since day 1, and have had no issues. MonoRail works very nicely with other DALs.
The nice thing is if you do a little planning, you can make your views DAL-agnostic. For example, in your above example, if you switched to another DAL but kept the same entity/property names, your view code could be exactly the same.
Hi Ayende !
I was looking for some kind of MVC for my application ( windows forms ), and found this project : www.codeplex.com/nmvp
Its a MVP implementation, works for asp.net and windows forms... take a look...
I was able to integrate our home grown O/RM into MonoRail in about 30 minutes and with less than 100 lines of code. (By integrate, I mean having controller methods receive arguments reconstituted through our O/RM.) I created a sub class of DataBinder, DataBindAttribute, and SmartDispatcherController
yes its possible to have MR work for any DAL, but before you try to use that with SubSonic, I still recommend you try ActiveRecord. I don't see a point to give up AR and use SubSonic DAL, I have tried both and applied on 1 CSK 2.0 project- believe me you don't want any DAL when u see how well AR works.
Comment preview