当前位置: 首页>>代码示例>>C#>>正文


C# SqlBuilder.SetTable方法代码示例

本文整理汇总了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;
		}
开发者ID:arangas,项目名称:MediaPortal-1,代码行数:44,代码来源:GentleProvider.cs


注:本文中的Gentle.Framework.SqlBuilder.SetTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。