C# Class Passive.DynamicModel

A class that wraps your database table in Dynamic Funtime
Afficher le fichier Open project: Talljoe/Passive

Méthodes publiques

Méthode Description
All ( object where = null, string orderBy = "", int limit, object columns = null ) : IEnumerable

Returns all records complying with the passed-in WHERE clause and arguments, ordered as specified, limited (TOP) by limit.

BuildCommands ( ) : List

Builds a set of Insert and Update commands based on the passed-on objects. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs

BuildCommandsWithWhitelist ( object whitelist ) : List

Builds a set of Insert and Update commands based on the passed-on objects. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs

Delete ( object key = null, object where = null ) : int

Removes one or more records from the DB according to the passed-in WHERE

DynamicModel ( DynamicDatabase database, string tableName = "", string primaryKeyField = "" ) : System

Initializes a new instance of the DynamicModel class.

DynamicModel ( string connectionStringName = "", string tableName = "", string primaryKeyField = "" ) : System

Initializes a new instance of the DynamicModel class.

GetPrimaryKey ( object o ) : object

If the object passed in has a property with the same name as your PrimaryKeyField it is returned here.

HasPrimaryKey ( object o ) : bool

Conventionally introspects the object passed in for a field that looks like a PK. If you've named your PrimaryKeyField, this becomes easy

Insert ( object o, object whitelist = null ) : object

Adds a record to the database. You can pass in an Anonymous object, an ExpandoObject, A regular old POCO, or a NameValueColletion from a Request.Form or Request.QueryString

Paged ( object where = null, string orderBy = "", object columns = null, int pageSize = 20, int currentPage = 1 ) : dynamic

Returns a dynamic PagedResult. Result properties are Items, TotalPages, and TotalRecords.

Save ( ) : int

Executes a set of objects as Insert or Update commands based on their property settings, within a transaction. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs

SaveWithWhitelist ( object whitelist ) : int

Executes a set of objects as Insert or Update commands based on their property settings, within a transaction. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs

Single ( object key = null, object where = null, object columns = null ) : dynamic

Returns a single row from the database

Update ( object o, object key, object whitelist = null ) : int

Updates a record in the database. You can pass in an Anonymous object, an ExpandoObject, A regular old POCO, or a NameValueCollection from a Request.Form or Request.QueryString

Méthodes protégées

Méthode Description
CreateDeleteCommand ( object key = null, object where = null ) : DynamicCommand

Removes one or more records from the DB according to the passed-in WHERE

CreateInsertCommand ( object o, object whitelist = null ) : DynamicCommand

Creates a command for use with transactions - internal stuff mostly, but here for you to play with

CreateUpdateCommand ( object o, object key, object whitelist = null ) : DynamicCommand

Creates a command for use with transactions - internal stuff mostly, but here for you to play with

Private Methods

Méthode Description
FilterItems ( object o, object whitelist ) : object>>.IEnumerable
GetColumn ( string propertyName, string columnName ) : string
GetColumns ( object columns ) : string
GetContext ( string method ) : string
GetWhereInfo ( object where, object key, IEnumerable args ) : WhereInfo
MapPrimaryKey ( object o ) : string

Method Details

All() public méthode

Returns all records complying with the passed-in WHERE clause and arguments, ordered as specified, limited (TOP) by limit.
public All ( object where = null, string orderBy = "", int limit, object columns = null ) : IEnumerable
where object
orderBy string
limit int
columns object
Résultat IEnumerable

BuildCommands() public méthode

Builds a set of Insert and Update commands based on the passed-on objects. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
public BuildCommands ( ) : List
Résultat List

BuildCommandsWithWhitelist() public méthode

Builds a set of Insert and Update commands based on the passed-on objects. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
public BuildCommandsWithWhitelist ( object whitelist ) : List
whitelist object
Résultat List

CreateDeleteCommand() protected méthode

Removes one or more records from the DB according to the passed-in WHERE
protected CreateDeleteCommand ( object key = null, object where = null ) : DynamicCommand
key object
where object
Résultat DynamicCommand

CreateInsertCommand() protected méthode

Creates a command for use with transactions - internal stuff mostly, but here for you to play with
protected CreateInsertCommand ( object o, object whitelist = null ) : DynamicCommand
o object
whitelist object
Résultat DynamicCommand

CreateUpdateCommand() protected méthode

Creates a command for use with transactions - internal stuff mostly, but here for you to play with
protected CreateUpdateCommand ( object o, object key, object whitelist = null ) : DynamicCommand
o object
key object
whitelist object
Résultat DynamicCommand

Delete() public méthode

Removes one or more records from the DB according to the passed-in WHERE
public Delete ( object key = null, object where = null ) : int
key object
where object
Résultat int

DynamicModel() public méthode

Initializes a new instance of the DynamicModel class.
public DynamicModel ( DynamicDatabase database, string tableName = "", string primaryKeyField = "" ) : System
database DynamicDatabase The database.
tableName string Name of the table.
primaryKeyField string The primary key field.
Résultat System

DynamicModel() public méthode

Initializes a new instance of the DynamicModel class.
public DynamicModel ( string connectionStringName = "", string tableName = "", string primaryKeyField = "" ) : System
connectionStringName string Name of the connection string.
tableName string Name of the table.
primaryKeyField string The primary key field.
Résultat System

GetPrimaryKey() public méthode

If the object passed in has a property with the same name as your PrimaryKeyField it is returned here.
public GetPrimaryKey ( object o ) : object
o object
Résultat object

HasPrimaryKey() public méthode

Conventionally introspects the object passed in for a field that looks like a PK. If you've named your PrimaryKeyField, this becomes easy
public HasPrimaryKey ( object o ) : bool
o object
Résultat bool

Insert() public méthode

Adds a record to the database. You can pass in an Anonymous object, an ExpandoObject, A regular old POCO, or a NameValueColletion from a Request.Form or Request.QueryString
public Insert ( object o, object whitelist = null ) : object
o object
whitelist object
Résultat object

Paged() public méthode

Returns a dynamic PagedResult. Result properties are Items, TotalPages, and TotalRecords.
public Paged ( object where = null, string orderBy = "", object columns = null, int pageSize = 20, int currentPage = 1 ) : dynamic
where object
orderBy string
columns object
pageSize int
currentPage int
Résultat dynamic

Save() public méthode

Executes a set of objects as Insert or Update commands based on their property settings, within a transaction. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
public Save ( ) : int
Résultat int

SaveWithWhitelist() public méthode

Executes a set of objects as Insert or Update commands based on their property settings, within a transaction. These objects can be POCOs, Anonymous, NameValueCollections, or Expandos. Objects With a PK property (whatever PrimaryKeyField is set to) will be created at UPDATEs
public SaveWithWhitelist ( object whitelist ) : int
whitelist object
Résultat int

Single() public méthode

Returns a single row from the database
public Single ( object key = null, object where = null, object columns = null ) : dynamic
key object
where object
columns object
Résultat dynamic

Update() public méthode

Updates a record in the database. You can pass in an Anonymous object, an ExpandoObject, A regular old POCO, or a NameValueCollection from a Request.Form or Request.QueryString
public Update ( object o, object key, object whitelist = null ) : int
o object
key object
whitelist object
Résultat int