Skip to content

OrmAbstractions

Craig Fowler edited this page Feb 22, 2020 · 2 revisions

The package CSF.ORM provides a small abstraction around a set of commonly-uses features of ORM software, primarily looking at NHibernate and its Linq functionality. It does this via two interfaces which business logic may consume:

  • IQuery
  • IPersister

Query functionality

The IQuery interface provides the following functions:

Get

This function gets an entity object from the data-source using its identity (primary key) value. If the entity does not exist in the data-source then this method will return null.

Theorise

This function returns a stand-in or proxy object which represents a theory that the entity with the specified identity (primary key) value exists in the underlying data-source. It does not use the data-source to verify whether this theory is correct or not, though.

For further information, read about when to use Theorise and when to use Get.

Query

The Query<T> method returns an IQueryable<T> object, upon which further Linq may be used. This provides an API with which to write dynamic queries upon the data-source.

The ORM API also provides a number of additional Linq extension methods which add additional functionality to IQueryable<T> objects.

Persister functionality

With all of the following methods, the 'Async' versions have identical functionality but use an async API, which will provide performance improvements when used in a suitable application architecture.

Add & AddAsync

These methods add a new object to the data-store which does not already exist there. The return value is that of the object identity/primary key value.

Update & UpdateAsync

These methods indicate to the underlying ORM that it should write changes made to the in-memory state of an object to the underlying data-store.

Delete & DeleteAsync

These methods instruct the ORM to remove an existing object from the data-store.

Clone this wiki locally