Skip to content
Jean-Pierre Bachmann edited this page Jun 12, 2016 · 1 revision

Basic usage

The basic part of the DataAccess project is the DbAccessLayer class. It contains several Generic and non generic functions to perform the 4 basic actions for each database.

  • Select
  • Update
  • Delete
  • Refresh

Before you start

The DbAccessLayer relies on an internal configuration that can be filled by using ether Attributes contained in the JPB.DataAccess.ModelsAnotations namespace. The most important one would be the ForModel attribute. This attribute allows you to "Rename" an property and maps this to an corresponding result Column. Use this if you want to mix conventions of you'r code with naming conventions on Database level. For example a column on a table is named 'User_Id' but you want to name the property just 'Id'. Then decorate the property with the ForModel attribute.

Select

There are 2 ways to select something from the database:

  • Selecting full Entitys (single [Annotation required] or multibe)
  • With Query Generation
  • Without Query Generation
  • With Factory usage
  • Selecting Scalar Values
  • Without Query Generation

For full Entitys you can choose to ether to:

  • Let the Framework generate the select statement
  • Provide you'r own statement that should return a ResultSet that matches the configuration of the given type
  • Create a factory function that provides conditional statements based on given Arguments or the internal state of Entity

Update

By taking care of an eventually exiting RowVersion field (Annotation required) the Entity will be updated on the Server. This requires an existing and filled PrimaryKey (Annotation required)

Delete

Deletes a single Row from the server by using the PrimaryKey (Annotation required)

Refresh

This is a non Database related function. It allows to refresh all Propertys on a given Entity by using its PrimaryKey (Annotation required)

Clone this wiki locally