C# 클래스 Massive.DynamicModel

A class that wraps your database table in Dynamic Funtime
파일 보기 프로젝트 열기: johnmbaughman/SQLiteConverter 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
Errors IList

공개 메소드들

메소드 설명
All ( string where = "", string orderBy = "", int limit, string columns = "*" ) : IEnumerable

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

BeforeDelete ( dynamic item ) : bool
BeforeSave ( dynamic item ) : bool
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

CreateDeleteCommand ( string where = "", object key = null ) : DbCommand

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

CreateFrom ( NameValueCollection coll ) : dynamic

Creates a new Expando from a Form POST - white listed against the columns in the DB

CreateInsertCommand ( dynamic expando ) : DbCommand
CreateUpdateCommand ( dynamic expando, object key ) : DbCommand

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

DefaultTo ( string key, object value, dynamic item ) : void
DefaultValue ( dynamic column ) : dynamic

Gets a default value for the column

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

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

Deleted ( dynamic item ) : void
DynamicModel ( ConnectionStringSettings connectionStringSettings, string tableName = "", string primaryKeyField = "" ) : System
DynamicModel ( string connectionStringName, string tableName = "", string primaryKeyField = "", string descriptorField = "" ) : System
Execute ( DbCommand command ) : int
Execute ( IEnumerable commands ) : int

Executes a series of DBCommands in a transaction

Execute ( string sql ) : int
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 ) : dynamic

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

Inserted ( dynamic item ) : void
IsValid ( dynamic item ) : bool
ItemAsDictionary ( ExpandoObject item ) : object>.IDictionary

This will return an Expando as a Dictionary

ItemContainsKey ( string key, ExpandoObject item ) : bool
KeyValues ( string orderBy = "" ) : object>.IDictionary

This will return a string/object dictionary for dropdowns etc

Open ( ConnectionStringSettings connectionStringSettings ) : DynamicModel
Open ( string connectionStringName ) : DynamicModel
OpenConnection ( ) : DbConnection

Returns and OpenConnection

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

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

Paged ( string sql, string primaryKey, string where = "", string orderBy = "", string columns = "*", int pageSize = 20, int currentPage = 1 ) : dynamic
Query ( string sql ) : IEnumerable

Enumerates the reader yielding the result - thanks to Jeroen Haegebaert

Query ( string sql, DbConnection connection ) : IEnumerable
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

Scalar ( string sql ) : object

Returns a single result

Single ( object key, string columns = "*" ) : dynamic

Returns a single row from the database

Single ( string where ) : dynamic

Returns a single row from the database

TryInvokeMember ( InvokeMemberBinder binder, object args, object &result ) : bool

A helpful query tool

Update ( object o, object key ) : 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

Updated ( dynamic item ) : void
Validate ( dynamic item ) : void
ValidateIsCurrency ( object value, string message = "Should be money" ) : void
ValidatesNumericalityOf ( object value, string message = "Should be a number" ) : void
ValidatesPresenceOf ( object value, string message = "Required" ) : void

비공개 메소드들

메소드 설명
BuildPagedResult ( string sql = "", string primaryKeyField = "", string where = "", string orderBy = "", string columns = "*", int pageSize = 20, int currentPage = 1 ) : dynamic
BuildSelect ( string where, string orderBy, int limit ) : string
CreateCommand ( string sql, DbConnection conn ) : DbCommand

Creates a DBCommand that you can use for loving your database.

메소드 상세

All() 공개 메소드

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

BeforeDelete() 공개 메소드

public BeforeDelete ( dynamic item ) : bool
item dynamic
리턴 bool

BeforeSave() 공개 메소드

public BeforeSave ( dynamic item ) : bool
item dynamic
리턴 bool

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

CreateDeleteCommand() 공개 메소드

Removes one or more records from the DB according to the passed-in WHERE
public CreateDeleteCommand ( string where = "", object key = null ) : DbCommand
where string
key object
리턴 DbCommand

CreateFrom() 공개 메소드

Creates a new Expando from a Form POST - white listed against the columns in the DB
public CreateFrom ( NameValueCollection coll ) : dynamic
coll NameValueCollection
리턴 dynamic

CreateInsertCommand() 공개 메소드

public CreateInsertCommand ( dynamic expando ) : DbCommand
expando dynamic
리턴 DbCommand

CreateUpdateCommand() 공개 메소드

Creates a command for use with transactions - internal stuff mostly, but here for you to play with
public CreateUpdateCommand ( dynamic expando, object key ) : DbCommand
expando dynamic
key object
리턴 DbCommand

DefaultTo() 공개 메소드

public DefaultTo ( string key, object value, dynamic item ) : void
key string
value object
item dynamic
리턴 void

DefaultValue() 공개 메소드

Gets a default value for the column
public DefaultValue ( dynamic column ) : dynamic
column dynamic
리턴 dynamic

Delete() 공개 메소드

Removes one or more records from the DB according to the passed-in WHERE
public Delete ( object key = null, string where = "" ) : int
key object
where string
리턴 int

Deleted() 공개 메소드

public Deleted ( dynamic item ) : void
item dynamic
리턴 void

DynamicModel() 공개 메소드

public DynamicModel ( ConnectionStringSettings connectionStringSettings, string tableName = "", string primaryKeyField = "" ) : System
connectionStringSettings ConnectionStringSettings
tableName string
primaryKeyField string
리턴 System

DynamicModel() 공개 메소드

public DynamicModel ( string connectionStringName, string tableName = "", string primaryKeyField = "", string descriptorField = "" ) : System
connectionStringName string
tableName string
primaryKeyField string
descriptorField string
리턴 System

Execute() 공개 메소드

public Execute ( DbCommand command ) : int
command DbCommand
리턴 int

Execute() 공개 메소드

Executes a series of DBCommands in a transaction
public Execute ( IEnumerable commands ) : int
commands IEnumerable
리턴 int

Execute() 공개 메소드

public Execute ( string sql ) : int
sql string
리턴 int

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 ) : dynamic
o object
리턴 dynamic

Inserted() 공개 메소드

public Inserted ( dynamic item ) : void
item dynamic
리턴 void

IsValid() 공개 메소드

public IsValid ( dynamic item ) : bool
item dynamic
리턴 bool

ItemAsDictionary() 공개 메소드

This will return an Expando as a Dictionary
public ItemAsDictionary ( ExpandoObject item ) : object>.IDictionary
item ExpandoObject
리턴 object>.IDictionary

ItemContainsKey() 공개 메소드

public ItemContainsKey ( string key, ExpandoObject item ) : bool
key string
item ExpandoObject
리턴 bool

KeyValues() 공개 메소드

This will return a string/object dictionary for dropdowns etc
public KeyValues ( string orderBy = "" ) : object>.IDictionary
orderBy string
리턴 object>.IDictionary

Open() 공개 정적인 메소드

public static Open ( ConnectionStringSettings connectionStringSettings ) : DynamicModel
connectionStringSettings ConnectionStringSettings
리턴 DynamicModel

Open() 공개 정적인 메소드

public static Open ( string connectionStringName ) : DynamicModel
connectionStringName string
리턴 DynamicModel

OpenConnection() 공개 메소드

Returns and OpenConnection
public OpenConnection ( ) : DbConnection
리턴 DbConnection

Paged() 공개 메소드

Returns a dynamic PagedResult. Result properties are Items, TotalPages, and TotalRecords.
public Paged ( string where = "", string orderBy = "", string columns = "*", int pageSize = 20, int currentPage = 1 ) : dynamic
where string
orderBy string
columns string
pageSize int
currentPage int
리턴 dynamic

Paged() 공개 메소드

public Paged ( string sql, string primaryKey, string where = "", string orderBy = "", string columns = "*", int pageSize = 20, int currentPage = 1 ) : dynamic
sql string
primaryKey string
where string
orderBy string
columns string
pageSize int
currentPage int
리턴 dynamic

Query() 공개 메소드

Enumerates the reader yielding the result - thanks to Jeroen Haegebaert
public Query ( string sql ) : IEnumerable
sql string
리턴 IEnumerable

Query() 공개 메소드

public Query ( string sql, DbConnection connection ) : IEnumerable
sql string
connection DbConnection
리턴 IEnumerable

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

Scalar() 공개 메소드

Returns a single result
public Scalar ( string sql ) : object
sql string
리턴 object

Single() 공개 메소드

Returns a single row from the database
public Single ( object key, string columns = "*" ) : dynamic
key object
columns string
리턴 dynamic

Single() 공개 메소드

Returns a single row from the database
public Single ( string where ) : dynamic
where string
리턴 dynamic

TryInvokeMember() 공개 메소드

A helpful query tool
public TryInvokeMember ( InvokeMemberBinder binder, object args, object &result ) : bool
binder InvokeMemberBinder
args object
result object
리턴 bool

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 ) : int
o object
key object
리턴 int

Updated() 공개 메소드

public Updated ( dynamic item ) : void
item dynamic
리턴 void

Validate() 공개 메소드

public Validate ( dynamic item ) : void
item dynamic
리턴 void

ValidateIsCurrency() 공개 메소드

public ValidateIsCurrency ( object value, string message = "Should be money" ) : void
value object
message string
리턴 void

ValidatesNumericalityOf() 공개 메소드

public ValidatesNumericalityOf ( object value, string message = "Should be a number" ) : void
value object
message string
리턴 void

ValidatesPresenceOf() 공개 메소드

public ValidatesPresenceOf ( object value, string message = "Required" ) : void
value object
message string
리턴 void

프로퍼티 상세

Errors 공개적으로 프로퍼티

public IList Errors
리턴 IList