C# 클래스 Passive.DynamicModel

A class that wraps your database table in Dynamic Funtime
파일 보기 프로젝트 열기: Talljoe/Passive

공개 메소드들

메소드 설명
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