Advanced

IUIOMaticRepository/AbstractUIOMaticRepository

By default, UI-O-Matic handles all CRUD operations of UIOMatic types out of the box for you, but if you'd like more fine grained control of how your entities are fetched, or if you'd like to perform CRUD operations yourself as well, for example, in an API layer, then you might want to take a look at creating your own repository.

To help, and to ensure your repository exposes the necesary methods for UI-O-Matic to do it's thing, we have created an interface for you to implement, IUIOMaticRepository

public interface IUIOMaticRepository
{
IEnumerable<object> GetAll(string sortColumn = "", string sortOrder = "");
UIOMaticPagedResult GetPaged(int pageNumber, int itemsPerPage,
string searchTerm = "",
IDictionary<string, string> filters = null,
string sortColumn = "", string sortOrder = "");
object Get(string id);
object Create(object entity);
object Update(object entity);
void Delete(string[] id);
long GetTotalRecordCount();
}

If you want a more strongly typed experience though, you may prefer to inherit the base class AbstractUIOMaticRepository

public abstract class AbstractUIOMaticRepository<TEntity, TId> : IUIOMaticRepository
{
public abstract IEnumerable<TEntity> GetAll(string sortColumn = "", string sortOrder = "");
public abstract UIOMaticPagedResult<TEntity> GetPaged(int pageNumber, int itemsPerPage,
string searchTerm = "",
IDictionary<string, string> filters = null,
string sortColumn = "", string sortOrder = "");
public abstract TEntity Get(TId id);
public abstract TEntity Create(TEntity entity);
public abstract TEntity Update(TEntity entity);
public abstract void Delete(TId[] ids);
long GetTotalRecordCount();
}

For example

public class PersonRepository : AbstractUIOMaticRepository<Person, int>
{
public override IEnumerable<Person> GetAll(string sortColumn = "", string sortOrder = "")
{
....
}
public override UIOMaticPagedResult<Person> GetPaged(int pageNumber, int itemsPerPage,
string searchTerm = "",
IDictionary<string, string> filters = null,
string sortColumn = "", string sortOrder = "")
{
....
}
public override Person Get(int id)
{
....
}
public override Person Create(Person entity)
{
....
}
public override Person Update(Person entity)
{
....
}
public override void Delete(int[] ids)
{
....
}
long GetTotalRecordCount()
{
....
}
}

Once you have a repository setup however, all you have to do is tell UI-O-Matic to use it by setting the RepositoryType parameter on the UIOMatic attribute of your type.

[UIOMatic("person", "People", "Person", RepositoryType = typeof(PersonRepository))]
public class Person
{
....
}

A complete example can be found in this gist https://gist.github.com/TimGeyssens/cff7e3ea5a31849cc71407ba1b6b4886 (it allows UI-0-Matic to CRUD issues on Github)

IUIOMaticObjectService

By default UIOMatic is using PetaPoco as it's ObjectService but you could swap that with a custom one by implementing the IUIOMaticObjectService interface and then switching the default provider type in the App_Plugins\UIOMatic\UIOMatic.config file

So you could replace PetaPoco for another ORM like Entity Framework