C# Class Subtext.Framework.Data.DataHelper

Contains helper methods for getting blog entries from the database into objects such as Entry
Afficher le fichier Open project: ayende/Subtext

Méthodes publiques

Méthode Description
CheckForNullString ( string text ) : object

If the string is empty or null, returns a System.DBNull.Value.

CheckNull ( System.DateTime dateTime ) : object

Checks the value of the specified value type for a null value. Returns null if the value represents a null value

CheckNull ( int obj ) : object

Checks the value type and returns null if the value is "null-equivalent".

CheckNull ( DBNull obj ) : string

Returns a true null if the object is DBNull.

CheckNull ( string obj ) : string

Returns an empty string if the value is null.

CheckNullString ( object obj ) : string

If the string is DBNull, returns null. Otherwise returns the string.

ExecuteDataTable ( SqlConnection connection, CommandType commandType, string commandText ) : DataTable

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.

e.g.: DataTable dt = ExecuteDataTable(conn, CommandType.StoredProcedure, "GetOrders");

ExecuteDataTable ( SqlTransaction transaction, CommandType commandType, string commandText ) : DataTable

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.

e.g.: DataTable dt = ExecuteDataTable(trans, CommandType.StoredProcedure, "GetOrders");

ExecuteDataTable ( string connectionString, CommandType commandType, string commandText ) : DataTable

Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in the connection string.

e.g.: DataTable dt = ExecuteDataTable(connString, CommandType.StoredProcedure, "GetOrders");

LoadArchiveCount ( IDataReader reader ) : IList
LoadArchiveLink ( IDataReader reader ) : Link
LoadBlogAlias ( IDataReader reader ) : BlogAlias

Loads the blog alias.

LoadBlogGroup ( IDataReader reader ) : BlogGroup
LoadConfigData ( IDataReader reader ) : BlogInfo
LoadEnclosure ( IDataReader reader ) : Enclosure
LoadEntry ( IDataReader reader ) : Entry
LoadEntryDayCollection ( IDataReader reader ) : IList
LoadEntryStatsView ( IDataReader reader ) : EntryStatsView
LoadEntryWithCategories ( IDataReader reader ) : Entry

Only use this when loading a SINGLE entry from a reader.

LoadHost ( IDataReader reader, HostInfo info ) : void

Loads the host from the data reader.

LoadImage ( IDataReader reader ) : Image
LoadKeyWord ( IDataReader reader ) : KeyWord
LoadLink ( DataRow dr ) : Link
LoadLink ( IDataReader reader ) : Link
LoadLinkCategory ( DataRow dr ) : LinkCategory
LoadLinkCategory ( IDataReader reader ) : LinkCategory
LoadLogEntry ( IDataReader reader ) : LogEntry

Loads the single log entry.

LoadMetaTag ( IDataReader reader ) : MetaTag
LoadReferrer ( IDataReader reader ) : Referrer
LoadTags ( IDataReader reader ) : int>.IDictionary
LoadViewStat ( IDataReader reader ) : ViewStat
MakeInParam ( string name, SqlDbType sqlType, int size, object value ) : SqlParameter

Make input param.

MakeInParam ( string ParamName, object Value ) : SqlParameter
MakeOutParam ( string ParamName, SqlDbType DbType, int Size ) : SqlParameter

Make input param.

MakeParam ( string ParamName, SqlDbType DbType, Int32 Size, ParameterDirection Direction, object Value ) : SqlParameter

Make stored procedure param.

ReadBoolean ( IDataReader reader, string columnName ) : bool

Reads a boolean from the data reader. If the value is null, returns false.

ReadDate ( IDataReader reader, string columnName ) : System.DateTime

Reads the date.

ReadDate ( IDataReader reader, string columnName, System.DateTime defaultValue ) : System.DateTime

Reads the date.

ReadInt32 ( IDataReader reader, string columnName ) : int

Reads the int from the data reader.

ReadInt32 ( IDataReader reader, string columnName, int defaultValue ) : int

Reads the int from the data reader. If the value is null, returns the default value.

ReadInt64 ( IDataReader reader, string columnName ) : long

Reads the long from the data reader.

ReadInt64 ( IDataReader reader, string columnName, long defaultValue ) : long

Reads the long from the data reader. If the value is null, returns the default value.

ReadIpAddress ( IDataReader reader, string columnName ) : IPAddress

Reads the string.

ReadNullableInt ( IDataReader reader, string columnName ) : int?

Reads the int from the data reader.

ReadString ( IDataReader reader, string columnName ) : string

Reads the string.

ReadUri ( IDataReader reader, string columnName ) : Uri

Reads an URI from the database.

ReturnNullIfEmpty ( string obj ) : string

Returns null if the value is an empty string.

Private Methods

Méthode Description
AttachParameters ( SqlCommand command, SqlParameter commandParameters ) : void

This method is used to attach array of SqlParameters to a SqlCommand. This method will assign a value of DbNull to any parameter with a direction of InputOutput and a value of null. This behavior will prevent default values from being used, but this will be the less common case than an intended pure output parameter (derived as InputOutput) where the user provided no input value.

DebugPrintCommand ( SqlCommand command ) : void
GetMaxItems ( IDataReader reader ) : int
IsNewDay ( System.DateTime dtCurrent, System.DateTime dtDay ) : bool
LoadEntry ( IDataReader reader, bool buildLinks ) : Entry
LoadEntry ( IDataReader reader, Entry entry, bool buildLinks ) : void
LoadEntryCollectionFromDataReader ( IDataReader reader ) : IList
LoadFeedbackItem ( IDataReader reader ) : FeedbackItem
LoadFeedbackItem ( IDataReader reader, Entry entry ) : FeedbackItem
LoadFeedbackItem ( IDataReader reader, FeedbackItem feedbackItem ) : void
PrepareCommand ( SqlCommand command, SqlConnection connection, SqlTransaction transaction, CommandType commandType, string commandText, SqlParameter commandParameters ) : void

This method opens (if necessary) and assigns a connection, transaction, command type and parameters to the provided command.

SetUrlPattern ( Entry entry ) : void

Method Details

CheckForNullString() public static méthode

If the string is empty or null, returns a System.DBNull.Value.
public static CheckForNullString ( string text ) : object
text string
Résultat object

CheckNull() public static méthode

Checks the value of the specified value type for a null value. Returns null if the value represents a null value
public static CheckNull ( System.DateTime dateTime ) : object
dateTime System.DateTime Date time.
Résultat object

CheckNull() public static méthode

Checks the value type and returns null if the value is "null-equivalent".
public static CheckNull ( int obj ) : object
obj int The obj.
Résultat object

CheckNull() public static méthode

Returns a true null if the object is DBNull.
public static CheckNull ( DBNull obj ) : string
obj System.DBNull The obj.
Résultat string

CheckNull() public static méthode

Returns an empty string if the value is null.
public static CheckNull ( string obj ) : string
obj string The obj.
Résultat string

CheckNullString() public static méthode

If the string is DBNull, returns null. Otherwise returns the string.
public static CheckNullString ( object obj ) : string
obj object The obj.
Résultat string

ExecuteDataTable() public static méthode

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection.
e.g.: DataTable dt = ExecuteDataTable(conn, CommandType.StoredProcedure, "GetOrders");
public static ExecuteDataTable ( SqlConnection connection, CommandType commandType, string commandText ) : DataTable
connection System.Data.SqlClient.SqlConnection a valid SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
Résultat System.Data.DataTable

ExecuteDataTable() public static méthode

Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlTransaction.
e.g.: DataTable dt = ExecuteDataTable(trans, CommandType.StoredProcedure, "GetOrders");
public static ExecuteDataTable ( SqlTransaction transaction, CommandType commandType, string commandText ) : DataTable
transaction System.Data.SqlClient.SqlTransaction a valid SqlTransaction
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
Résultat System.Data.DataTable

ExecuteDataTable() public static méthode

Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in the connection string.
e.g.: DataTable dt = ExecuteDataTable(connString, CommandType.StoredProcedure, "GetOrders");
public static ExecuteDataTable ( string connectionString, CommandType commandType, string commandText ) : DataTable
connectionString string a valid connection string for a SqlConnection
commandType CommandType the CommandType (stored procedure, text, etc.)
commandText string the stored procedure name or T-SQL command
Résultat System.Data.DataTable

LoadArchiveCount() public static méthode

public static LoadArchiveCount ( IDataReader reader ) : IList
reader IDataReader
Résultat IList

LoadArchiveLink() public static méthode

public static LoadArchiveLink ( IDataReader reader ) : Link
reader IDataReader
Résultat Subtext.Framework.Components.Link

LoadBlogAlias() public static méthode

Loads the blog alias.
public static LoadBlogAlias ( IDataReader reader ) : BlogAlias
reader IDataReader The reader.
Résultat BlogAlias

LoadBlogGroup() public static méthode

public static LoadBlogGroup ( IDataReader reader ) : BlogGroup
reader IDataReader
Résultat Subtext.Framework.Components.BlogGroup

LoadConfigData() public static méthode

public static LoadConfigData ( IDataReader reader ) : BlogInfo
reader IDataReader
Résultat BlogInfo

LoadEnclosure() public static méthode

public static LoadEnclosure ( IDataReader reader ) : Enclosure
reader IDataReader
Résultat Subtext.Framework.Components.Enclosure

LoadEntry() public static méthode

public static LoadEntry ( IDataReader reader ) : Entry
reader IDataReader
Résultat Subtext.Framework.Components.Entry

LoadEntryDayCollection() public static méthode

public static LoadEntryDayCollection ( IDataReader reader ) : IList
reader IDataReader
Résultat IList

LoadEntryStatsView() public static méthode

public static LoadEntryStatsView ( IDataReader reader ) : EntryStatsView
reader IDataReader
Résultat Subtext.Framework.Components.EntryStatsView

LoadEntryWithCategories() public static méthode

Only use this when loading a SINGLE entry from a reader.
public static LoadEntryWithCategories ( IDataReader reader ) : Entry
reader IDataReader
Résultat Subtext.Framework.Components.Entry

LoadHost() public static méthode

Loads the host from the data reader.
public static LoadHost ( IDataReader reader, HostInfo info ) : void
reader IDataReader Reader.
info HostInfo HostInfo
Résultat void

LoadImage() public static méthode

public static LoadImage ( IDataReader reader ) : Image
reader IDataReader
Résultat Image

LoadKeyWord() public static méthode

public static LoadKeyWord ( IDataReader reader ) : KeyWord
reader IDataReader
Résultat Subtext.Framework.Components.KeyWord

LoadLink() public static méthode

public static LoadLink ( DataRow dr ) : Link
dr System.Data.DataRow
Résultat Subtext.Framework.Components.Link

LoadLink() public static méthode

public static LoadLink ( IDataReader reader ) : Link
reader IDataReader
Résultat Subtext.Framework.Components.Link

LoadLinkCategory() public static méthode

public static LoadLinkCategory ( DataRow dr ) : LinkCategory
dr System.Data.DataRow
Résultat Subtext.Framework.Components.LinkCategory

LoadLinkCategory() public static méthode

public static LoadLinkCategory ( IDataReader reader ) : LinkCategory
reader IDataReader
Résultat Subtext.Framework.Components.LinkCategory

LoadLogEntry() public static méthode

Loads the single log entry.
public static LoadLogEntry ( IDataReader reader ) : LogEntry
reader IDataReader The reader.
Résultat Subtext.Framework.Logging.LogEntry

LoadMetaTag() public static méthode

public static LoadMetaTag ( IDataReader reader ) : MetaTag
reader IDataReader
Résultat Subtext.Framework.Components.MetaTag

LoadReferrer() public static méthode

public static LoadReferrer ( IDataReader reader ) : Referrer
reader IDataReader
Résultat Subtext.Framework.Components.Referrer

LoadTags() public static méthode

public static LoadTags ( IDataReader reader ) : int>.IDictionary
reader IDataReader
Résultat int>.IDictionary

LoadViewStat() public static méthode

public static LoadViewStat ( IDataReader reader ) : ViewStat
reader IDataReader
Résultat Subtext.Framework.Components.ViewStat

MakeInParam() public static méthode

Make input param.
public static MakeInParam ( string name, SqlDbType sqlType, int size, object value ) : SqlParameter
name string Name of param.
sqlType SqlDbType Param type.
size int Param size.
value object Param value.
Résultat System.Data.SqlClient.SqlParameter

MakeInParam() public static méthode

public static MakeInParam ( string ParamName, object Value ) : SqlParameter
ParamName string
Value object
Résultat System.Data.SqlClient.SqlParameter

MakeOutParam() public static méthode

Make input param.
public static MakeOutParam ( string ParamName, SqlDbType DbType, int Size ) : SqlParameter
ParamName string Name of param.
DbType SqlDbType Param type.
Size int Param size.
Résultat System.Data.SqlClient.SqlParameter

MakeParam() public static méthode

Make stored procedure param.
public static MakeParam ( string ParamName, SqlDbType DbType, Int32 Size, ParameterDirection Direction, object Value ) : SqlParameter
ParamName string Name of param.
DbType SqlDbType Param type.
Size System.Int32 Param size.
Direction ParameterDirection Parm direction.
Value object Param value.
Résultat System.Data.SqlClient.SqlParameter

ReadBoolean() public static méthode

Reads a boolean from the data reader. If the value is null, returns false.
public static ReadBoolean ( IDataReader reader, string columnName ) : bool
reader IDataReader The reader.
columnName string Name of the column.
Résultat bool

ReadDate() public static méthode

Reads the date.
public static ReadDate ( IDataReader reader, string columnName ) : System.DateTime
reader IDataReader The reader.
columnName string Name of the column.
Résultat System.DateTime

ReadDate() public static méthode

Reads the date.
public static ReadDate ( IDataReader reader, string columnName, System.DateTime defaultValue ) : System.DateTime
reader IDataReader The reader.
columnName string Name of the column.
defaultValue System.DateTime The default value.
Résultat System.DateTime

ReadInt32() public static méthode

Reads the int from the data reader.
public static ReadInt32 ( IDataReader reader, string columnName ) : int
reader IDataReader The reader.
columnName string Name of the column.
Résultat int

ReadInt32() public static méthode

Reads the int from the data reader. If the value is null, returns the default value.
public static ReadInt32 ( IDataReader reader, string columnName, int defaultValue ) : int
reader IDataReader The reader.
columnName string Name of the column.
defaultValue int devault value for the field
Résultat int

ReadInt64() public static méthode

Reads the long from the data reader.
public static ReadInt64 ( IDataReader reader, string columnName ) : long
reader IDataReader The reader.
columnName string Name of the column.
Résultat long

ReadInt64() public static méthode

Reads the long from the data reader. If the value is null, returns the default value.
public static ReadInt64 ( IDataReader reader, string columnName, long defaultValue ) : long
reader IDataReader The reader.
columnName string Name of the column.
defaultValue long devault value for the field
Résultat long

ReadIpAddress() public static méthode

Reads the string.
public static ReadIpAddress ( IDataReader reader, string columnName ) : IPAddress
reader IDataReader The reader.
columnName string Name of the coumn.
Résultat System.Net.IPAddress

ReadNullableInt() public static méthode

Reads the int from the data reader.
public static ReadNullableInt ( IDataReader reader, string columnName ) : int?
reader IDataReader The reader.
columnName string Name of the column.
Résultat int?

ReadString() public static méthode

Reads the string.
public static ReadString ( IDataReader reader, string columnName ) : string
reader IDataReader The reader.
columnName string Name of the coumn.
Résultat string

ReadUri() public static méthode

Reads an URI from the database.
public static ReadUri ( IDataReader reader, string columnName ) : Uri
reader IDataReader
columnName string
Résultat System.Uri

ReturnNullIfEmpty() public static méthode

Returns null if the value is an empty string.
public static ReturnNullIfEmpty ( string obj ) : string
obj string The obj.
Résultat string