This project is read-only.

The following data extension points are marked as abstract in ResourceController<TModel> . They must be overridden in your controller.

object AddModel(TModel model)
You have to write the code for how a model gets added to your data store. This can call your ORM object context directly (such as a Linq-toSQL DataContext, or NHibernate ISession), a service tier, or do nothing at all. It should return the ID of the newly created object.

void DeleteModel(object id)
Delete a model from the data store with the given ID. Depending on your application requirements, you may choose other outcomes for your delete action. For example, I frequently work on projects where all records have an IsDeleted column (aka soft deletes). All queries should work against IsDelete == false . In this case, the delete action is really to set model.IsDeleted = true; .

TModel GetModel(object id)
Get a model with the given ID from the data store.

IEnumerable<TModel> GetModels()
Get a collection of models from the data store.

void SaveModel(TModel model)
Save an existing record to the data store.

The following data extension points are marked as virtual in ResourceController<TModel>.

int GetCount()
Count the number of records. This is only needed if paging is supported in your application.

int GetPageCount(int modelCount)
Get the number of pages in your application. If using the built-in pager, then you shouldn't override this method. However, you may have your own way of calculating the number pages, so this is left open.

TModel GetDefaultModel()
Used as part of the New() operation. By default, we use Activator.CreateInstance<TModel> . If you have other values that you need to set by default on your model, then you should override this method.

Last edited Dec 8, 2010 at 5:14 PM by jarrettmeyer, version 1


No comments yet.