本文整理汇总了C#中Gentle.Framework.SqlBuilder.SetTable方法的典型用法代码示例。如果您正苦于以下问题:C# SqlBuilder.SetTable方法的具体用法?C# SqlBuilder.SetTable怎么用?C# SqlBuilder.SetTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gentle.Framework.SqlBuilder
的用法示例。
在下文中一共展示了SqlBuilder.SetTable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStatement
/// <summary>
/// Retrieve a statement from the cache. If the statement is not present it will be generated
/// and added to the cache.
/// </summary>
/// <param name="type">The business object with which the statement is associated</param>
/// <param name="tableName">The table used in the statement</param>
/// <param name="stmtType">The type of the SQL statement</param>
/// <returns>An SqlStatement instance</returns>
public SqlStatement GetStatement( Type type, string tableName, StatementType stmtType )
{
Initialize(); // ensure thread local variables have been initialized
SqlStatement stmt;
Hashtable stmts = (Hashtable) stmtByType[ type ];
// check if an SqlStatement has been cached for the given type and StatementType
bool isCached = stmts != null && stmts.ContainsKey( stmtType );
if( isCached )
{
stmt = (SqlStatement) stmts[ stmtType ];
// the npgsql library for postgres does not allow us to update the connection
// property when a transaction is active
if( stmt.Command.Connection == null || providerName != "PostgreSQL" )
{
// make sure statement broker reference is updated before returning it
stmt.SessionBroker = Broker;
return stmt;
}
}
// otherwise create and return fresh object
PersistenceBroker broker = new PersistenceBroker( this );
SqlBuilder sb = new SqlBuilder( broker, stmtType, type );
// set the table name specified in the key (if null the default will be used instead)
sb.SetTable( tableName );
// get the statement using primary key fields as constraints
stmt = sb.GetStatement( false );
// dont cache statements for objects that map to multiple tables
ObjectMap map = ObjectFactory.GetMap( broker, type );
if( ! (map.IsDynamicTable || isCached) )
{
// TODO Prepare only works with a connection :-(
// stmt.Prepare();
CacheStatement( type, stmtType, stmt );
}
return stmt;
}