Ayende @ Rahien

Hi!
My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 18 | Comments: 79

filter by tags archive

MonoRail With SubSonic

time to read 4 min | 601 words

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 class ProductsController
{
 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

Steve Harman

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!

Brian

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.

Paulo Quicoli

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...

Christopher Bennage

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

goodwill

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

Comments have been closed on this topic.

FUTURE POSTS

  1. The insidious cost of allocations - one day from now
  2. Buffer allocation strategies: A possible solution - 4 days from now
  3. Buffer allocation strategies: Explaining the solution - 5 days from now
  4. Buffer allocation strategies: Bad usage patterns - 6 days from now
  5. The useless text book algorithms - 7 days from now

And 1 more posts are pending...

There are posts all the way to Sep 11, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    03 Sep 2015 - The industry at large
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats