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


C# ISessionImplementor.GetPersister方法代码示例

本文整理汇总了C#中ISessionImplementor.GetPersister方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionImplementor.GetPersister方法的具体用法?C# ISessionImplementor.GetPersister怎么用?C# ISessionImplementor.GetPersister使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ISessionImplementor的用法示例。


在下文中一共展示了ISessionImplementor.GetPersister方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Generate

		/// <summary>
		/// Generates a new identifier by getting the value of the identifier
		/// for the <c>obj</c> parameter.
		/// </summary>
		/// <param name="session">The <see cref="ISessionImplementor"/> this id is being generated in.</param>
		/// <param name="obj">The entity for which the id is being generated.</param>
		/// <returns>The value that was assigned to the mapped <c>id</c>'s property.</returns>
		/// <exception cref="IdentifierGenerationException">
		/// Thrown when a <see cref="PersistentCollection"/> is passed in as the <c>obj</c> or
		/// if the identifier of <c>obj</c> is null.
 		/// </exception>
		public object Generate( ISessionImplementor session, object obj )
		{
			if( obj is PersistentCollection )
			{
				throw new IdentifierGenerationException(
					"Illegal use of assigned id generation for a toplevel collection"
					);
			}

			object id = session.GetPersister( obj ).GetIdentifier( obj );
			if( id == null )
			{
				throw new IdentifierGenerationException(
					"ids for this class must be manually assigned before calling save(): " + obj.GetType().FullName
					);
			}
			return id;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:29,代码来源:Assigned.cs

示例2: LoadFromResultSet

		/// <summary>
		/// Hydrate the state of an object from the SQL <c>IDataReader</c>, into
		/// an array of "hydrated" values (do not resolve associations yet),
		/// and pass the hydrated state to the session.
		/// </summary>
		/// <param name="rs"></param>
		/// <param name="i"></param>
		/// <param name="obj"></param>
		/// <param name="key"></param>
		/// <param name="suffix"></param>
		/// <param name="lockMode"></param>
		/// <param name="rootPersister"></param>
		/// <param name="session"></param>
		private void LoadFromResultSet( IDataReader rs, int i, object obj, Key key, string suffix, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session )
		{
			if( log.IsDebugEnabled )
			{
				log.Debug( "Initializing object from DataReader: " + key );
			}

			// add temp entry so that the next step is circular-reference
			// safe - only needed because some types don't take proper
			// advantage of two-phase-load (esp. components)
			session.AddUninitializedEntity( key, obj, lockMode );

			// Get the persister for the _subclass_
			ILoadable persister = ( ILoadable ) session.GetPersister( obj );

			// This is not very nice (and quite slow):
			string[ ][ ] cols = persister == rootPersister ?
				suffixedPropertyColumns[ i ] :
				GetSuffixedPropertyAliases( persister, suffix );

			object id = key.Identifier;
			object[ ] values = Hydrate( rs, id, obj, persister, session, cols );
			session.PostHydrate( persister, id, values, obj, lockMode );
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:37,代码来源:Loader.cs

示例3: GetRowFromResultSet

		private object GetRowFromResultSet(
			IDataReader resultSet,
			ISessionImplementor session,
			QueryParameters queryParameters,
			IList hydratedObjects,
			object optionalObject,
			object optionalId,
			Key[ ] keys,
			bool returnProxies )
		{
			ILoadable[ ] persisters = Persisters;
			int cols = persisters.Length;
			ICollectionPersister collectionPersister = CollectionPersister;
			int collectionOwner = CollectionOwner;
			string[ ] suffixes = Suffixes;
			LockMode[ ] lockModeArray = GetLockModes( queryParameters.LockModes );
			int[ ] owners = Owners;

			// this is a CollectionInitializer and we are loading up a single collection
			bool hasCollections = collectionPersister != null;
			// this is a query and we are loading multiple instances of the same collection role
			bool hasCollectionOwners = hasCollections && collectionOwner >= 0;

			Key optionalObjectKey;

			if( optionalObject != null )
			{
				optionalObjectKey = new Key( optionalId, session.GetPersister( optionalObject ) );
			}
			else
			{
				optionalObjectKey = null;
			}

			for( int i = 0; i < cols; i++ )
			{
				keys[ i ] = GetKeyFromResultSet(
					i,
					Persisters[ i ],
					( i == cols - 1 ) ? optionalId : null,
					resultSet,
					session );
				//TODO: the i==cols-1 bit depends upon subclass implementation (very bad)
			}

			if( owners != null )
			{
				RegisterNonExists( keys, owners, persisters, session );
			}

			// this call is side-effecty
			object[ ] row = GetRow(
				resultSet,
				persisters,
				suffixes,
				keys,
				optionalObject,
				optionalObjectKey,
				lockModeArray,
				hydratedObjects,
				session );

			if( returnProxies )
			{
				for( int i = 0; i < cols; i++ )
				{
					// now get an existing proxy for each row element (if there is one)
					row[ i ] = session.ProxyFor( persisters[ i ], keys[ i ], row[ i ] );
				}
			}

			if( hasCollections )
			{
				//if null, owner will be retrieved from session
				object owner = hasCollectionOwners ? row[ collectionOwner ] : null;
				object key = owner != null
					? keys[ collectionOwner ].Identifier : null;
				ReadCollectionElement( owner, key, resultSet, session );
			}

			return GetResultColumnOrRow( row, resultSet, session );
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:82,代码来源:Loader.cs


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