Thursday, November 4, 2010

Data Access with Cheetah Framework.



  As I mentioned in my previous post, I am working on a Framework(Cheetah Framework) that will help developers writing SaaS applications with asp.net MVC, in this post I will be talking about how the Cheetah Framework help developers with the data access for SaaS applications.
First of all, usually there are three main ways that the data is stored on the server:

  1. Isolated Schema, isolated database.
  2. Isolated Schema, shared database.
  3. Shares schema, shared database.
For more information about advantages and disadvantages about each model you can go here


Cheetah Framework uses the third option, i.e. shared schema, shared database, to make it work, Cheetah Framework needs you to follow some simple rules when creating your database, oh and by the way, Cheetah Framework supports SQL server and SQL Azure, once you have your database defined, you need to configure just one connection string and update one single file(no single line of code involved) and Cheetah Framework takes control from there, just compile your project and you will have access to functionality that was generated for you.

Cheetah Framework will automatically filter the data based on the active tenant so developers will work with the data as if they were developing a single tenant application, also Cheetah Framework has built in support that allows the tenant to extend any table in their database, so, for instance, developers can define a base table "Products" with a fixed set of fields and each tenant will be able to extend the "Products" table to fit their needs, in terms of code, developers can access those extended fields directly as if they were part of the "Products" table, something like:

NewProduct.MyCustomField = "test"

This feature is also useful when creating verticals, lets said that you are creating a  Time Track SaaS application, you can define a vanilla app and then define extended fields for specific verticals, like Time Track for Developers, Time Track for Doctors, Time Track for teachers, and so on, also each vertical's tenant will be able to add their own custom fields.

The following is an example with the current version of the Cheetah Framework that was added to a vanilla MVC application:
This is the aspnet_Users table: 











As you can see the field "FirstName" is not part of this table.
This is the basic code that you will need in the controller:

And this is a simple example of  the View :
 


As you can see, you use the extended field "FirstName" as it was part of the original object, any extended fields can be accessed that way.


Well, thats all for now, in the next post I will continue talking about how the data is accessed and other things that Cheetah Framework does for you.

No comments:

Post a Comment