C# Класс Passive.DynamicModel

A class that wraps your database table in Dynamic Funtime
Показать файл Открыть проект

Открытые методы

Метод Описание
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

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
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

Описание методов

All() публичный Метод

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
Результат IEnumerable

BuildCommands() публичный Метод

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
Результат List

BuildCommandsWithWhitelist() публичный Метод

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
Результат List

CreateDeleteCommand() защищенный Метод

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
Результат DynamicCommand

CreateInsertCommand() защищенный Метод

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
Результат DynamicCommand

CreateUpdateCommand() защищенный Метод

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
Результат DynamicCommand

Delete() публичный Метод

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
Результат int

DynamicModel() публичный Метод

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.
Результат System

DynamicModel() публичный Метод

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.
Результат System

GetPrimaryKey() публичный Метод

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
Результат object

HasPrimaryKey() публичный Метод

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
Результат bool

Insert() публичный Метод

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
Результат object

Paged() публичный Метод

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
Результат dynamic

Save() публичный Метод

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
Результат int

SaveWithWhitelist() публичный Метод

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
Результат int

Single() публичный Метод

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
Результат dynamic

Update() публичный Метод

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
Результат int