Skip to content

Factorys

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

Factorys can be used to provide user made query generation. There are 4 Factorys you can provide.

  • SelectFactoryMethod (Static)
  • InsertFactoryMethod (Instance)
  • UpdateFactoryMethod (Instance)
  • DeleteFactoryMethod (Instance)

For each Database related method you can provide a Factory. The select Factory is a bit special as it requires no instance. All Factorys has to be defined as a method on the related Entity and has to be annotated with the corresponding attribute.

The General signature are equal for all Factorys.

[{Method}FactoryMethod] public !static {string|IQueryFactoryResult|void} Name (*)

"public" for syntactic reasons, all factory functions are required to be public "static" Only for SelectFactorys. "string|IQueryFactoryResult|void" you can return ether a plain string, an Instance of an IQueryFactoryResult or nothing(see next). "*" The arguments are the interesting part. You can define as many arguments you want to, even Complex objects. In addition to that you can define an RootQuery argument that will be injected into the function. In this case the Factory must return void. In all other cases where a factory does not define an RootQuery the factory MUST return ether a string for an IQueryFactory. When defining the RootQuery argument fill the query object to generate the desired query.

SelectFactoryMethod

In addition to all other requirements a SelectFactory must be static as no instance of the Entity is known at QueryGeneration time.

Clone this wiki locally