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


C# ISessionImplementor.GetEntityIdentifierIfNotUnsaved方法代码示例

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


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

示例1: IdentityRemove

		public static void IdentityRemove( IList list, object obj, ISessionImplementor session )
		{
			int indexOfEntityToRemove = -1;

			if( session.IsSaved( obj ) )
			{
				object idOfCurrent = session.GetEntityIdentifierIfNotUnsaved( obj );
				for( int i = 0; i < list.Count; i++ )
				{
					object idOfOld = session.GetEntityIdentifierIfNotUnsaved( list[ i ] );
					if( idOfCurrent.Equals( idOfOld ) )
					{
						// in hibernate this used the Iterator to remove the item - since in .NET
						// the Enumerator is read only we have to change the implementation slightly. 
						indexOfEntityToRemove = i;
						break;
					}
				}

				if( indexOfEntityToRemove != -1 )
				{
					list.RemoveAt( indexOfEntityToRemove );
				}
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:25,代码来源:PersistentCollection.cs

示例2: Disassemble

		public override object Disassemble(object value, ISessionImplementor session)
		{
			if (value == null)
			{
				return null;
			}
			else
			{
				// cache the actual id of the object, not the value of the
				// property-ref, which might not be initialized
				object id = session.GetEntityIdentifierIfNotUnsaved(value);
				if (id == null)
				{
					throw new AssertionFailure("cannot cache a reference to an object with a null id: " + AssociatedClass.Name);
				}
				return GetIdentifierType(session).Disassemble(id, session);
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:18,代码来源:ManyToOneType.cs

示例3: GetOrphans

		protected static ICollection GetOrphans( ICollection oldElements, ICollection currentElements, ISessionImplementor session )
		{
			// short-circuit(s)
			if ( currentElements.Count == 0 )
			{
				// no new elements, the old list contains only Orphans
				return oldElements;
			}
			if ( oldElements.Count == 0 )
			{
				// no old elements, so no Orphans neither
				return oldElements;
			}

			// create the collection holding the orphans
			IList res = new ArrayList();

			// collect EntityIdentifier(s) of the *current* elements - add them into a HashSet for fast access
			ISet currentIds = new HashedSet();
			foreach ( object current in currentElements )
			{
				if ( session.IsSaved( current ) )
				{
					currentIds.Add( session.GetEntityIdentifierIfNotUnsaved( current ) );
				}
			}

			// iterate over the *old* list
			foreach ( object old in oldElements )
			{
				object id = session.GetEntityIdentifierIfNotUnsaved( old );
				if ( !currentIds.Contains( id ) )
				{
					res.Add( old );
				}
			}

			return res;
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:39,代码来源:PersistentCollection.cs

示例4: Id

		private object Id( object component, ISessionImplementor session )
		{
			try
			{
				return session.GetEntityIdentifierIfNotUnsaved( component );
			}
			catch( TransientObjectException )
			{
				return null;
			}
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:11,代码来源:ObjectType.cs

示例5: NullSafeSet

		public override void NullSafeSet( IDbCommand st, object value, int index, ISessionImplementor session )
		{
			object id;
			System.Type clazz;

			if( value == null )
			{
				id = null;
				clazz = null;
			}
			else
			{
				id = session.GetEntityIdentifierIfNotUnsaved( value );
				clazz = NHibernateProxyHelper.GetClass( value );
			}
			metaType.NullSafeSet( st, clazz, index, session );
			identifierType.NullSafeSet( st, id, index + 1, session ); // metaType must be single-column type
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:18,代码来源:ObjectType.cs

示例6: GetIdentifier

		protected object GetIdentifier(object value, ISessionImplementor session)
		{
			if (IsReferenceToPrimaryKey)
			{
				return session.GetEntityIdentifierIfNotUnsaved(value); //tolerates nulls
			}
			else if (value == null)
			{
				return null;
			}
			else
			{
				return session.Factory
					.GetEntityPersister(AssociatedClass)
					.GetPropertyValue(value, uniqueKeyPropertyName);
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:17,代码来源:EntityType.cs

示例7: Replace

		public override object Replace(object original, object current, ISessionImplementor session, object owner,
		                               IDictionary copiedAlready)
		{
			if (original == null)
			{
				return null;
			}
			else
			{
				System.Type entityClass = NHibernateProxyHelper.GuessClass(original);
				object id = session.GetEntityIdentifierIfNotUnsaved(original);
				return session.InternalLoad(
						entityClass,
						id,
						false,
						false
					);
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:19,代码来源:AnyType.cs

示例8: NullSafeSet

		public override void NullSafeSet(IDbCommand st, object value, int index, bool[] settable, ISessionImplementor session)
		{
			object id;
			System.Type clazz;

			if (value == null)
			{
				id = null;
				clazz = null;
			}
			else
			{
				id = session.GetEntityIdentifierIfNotUnsaved(value);
				clazz = NHibernateProxyHelper.GuessClass(value);
			}

			// metaType is assumed to be single-column type
			if (settable == null || settable[0])
			{
				metaType.NullSafeSet(st, clazz, index, session);
			}

			if (settable == null)
			{
				identifierType.NullSafeSet(st, id, index + 1, session);
			}
			else
			{
				bool[] idsettable = new bool[settable.Length - 1];
				Array.Copy(settable, 1, idsettable, 0, idsettable.Length);
				identifierType.NullSafeSet(st, id, index + 1, idsettable, session);
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:33,代码来源:AnyType.cs


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