Anyone have an example SS project they feel would be a good candidate for a generated model-first CRUD project? I’ve been trying to use Telerik’s ORM and it’s brutal. Every request to their Support team yields the same response; “You’ll have to extend the generated project.” So, since it makes no sense to write that much code AND be dependent on a third-party product, it looks like I’m gonna build a template or three. I’d love as much input as possible before I begin. Hopefully it’ll be useful to others as well.
Stephen Brannan:
When you say generated model first? What would the generator generate from? I might be able to help given more info.
Fredrick Lackey:
Initially I intended on using a design tool to create the model. Now I’m thinking of pulling directly from the database. At the moment I’m trying to find more simple / extensible SS projects. The patterns I’ve been using work well, but they’re a bit more verbose.
Stephen Brannan:
Ah schema first is what your looking for. Unfortunately I’m not aware of such a generator for ServiceStack. It wouldn’t be too terribly hard to query sys.schemas, sys.tables, sys.columns, etc (SQL Server). But obviously that doesn’t help you much.
The way I would tackle this is to perhaps make a common Service class to handle simple CRUD calls (i.e. GET/PUT(Update)/POST(Add)/DELETE) that takes the models automatically and persists them to the db through a single generic Db service or repo. Then I would write a C# generator (a console app would do here) to create your Models and Services. The services you generate would inherit from the common service class to minimize code duplication.
For templating C# quickly there is T4 Text Templates which is popular but I haven’t used it myself. There is another one that I’ve used called DotLiquid that works well for this.
If you want to go the NHibernate route for ORM I have a few wrapper & infrastructure classes that integrate with Servicestack I can probably share if you’d like.
Fredrick Lackey:
Sorry for the confusion. Building templates for SS is a snap… been doing it for years. I was trying to find an example SS web service project to compare with mine before beginning.
As far as existing schema-first examples, the only one I know of is Telerik’s ORM product. It will generate a CRUD web service, however it’s quite limiting.