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


C# IEntityPersister.GetIdentifier方法代码示例

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


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

示例1: CheckId

        /// <summary>
        /// make sure user didn't mangle the id
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="persister"></param>
        /// <param name="id"></param>
        /// <param name="entityMode"></param>
        public virtual void CheckId(object obj, IEntityPersister persister, object id, EntityMode entityMode)
        {
            if (id != null && id is DelayedPostInsertIdentifier)
            {
                // this is a situation where the entity id is assigned by a post-insert generator
                // and was saved outside the transaction forcing it to be delayed
                return;
            }

            if (persister.CanExtractIdOutOfEntity)
            {
                object oid = persister.GetIdentifier(obj, entityMode);
                if (id == null)
                {
                    throw new AssertionFailure("null id in " + persister.EntityName + " entry (don't flush the Session after an exception occurs)");
                }
                if (!persister.IdentifierType.IsEqual(id, oid, EntityMode.Poco))
                {
                    throw new HibernateException("identifier of an instance of " + persister.EntityName + " was altered from " + id + " to " + oid);
                }
            }
        }
开发者ID:zibler,项目名称:zibler,代码行数:29,代码来源:DefaultFlushEntityEventListener.cs

示例2: GetIdentifier

		/// <summary> 
		/// Get the identifier value of an instance or proxy.
		/// <p/>
		/// Intended only for loggin purposes!!!
		/// </summary>
		/// <param name="obj">The object from which to extract the identifier.</param>
		/// <param name="persister">The entity persister </param>
		/// <param name="entityMode">The entity mode </param>
		/// <returns> The extracted identifier. </returns>
		private static object GetIdentifier(object obj, IEntityPersister persister, EntityMode entityMode)
		{
			if (obj.IsProxy())
			{
				INHibernateProxy proxy = obj as INHibernateProxy; 
				ILazyInitializer li = proxy.HibernateLazyInitializer;
				
				return li.Identifier;
			}
			else
			{
				return persister.GetIdentifier(obj, entityMode);
			}
		}
开发者ID:KaraokeStu,项目名称:nhibernate-core,代码行数:23,代码来源:EntityType.cs

示例3: ExistsInDatabase

		private static bool ExistsInDatabase(object entity, IEventSource source, IEntityPersister persister)
		{
			EntityEntry entry = source.PersistenceContext.GetEntry(entity);
			if (entry == null)
			{
				object id = persister.GetIdentifier(entity, source.EntityMode);
				if (id != null)
				{
					EntityKey key = new EntityKey(id, persister, source.EntityMode);
					object managedEntity = source.PersistenceContext.GetEntity(key);
					entry = source.PersistenceContext.GetEntry(managedEntity);
				}
			}

			if (entry == null)
			{
				// perhaps this should be an exception since it is only ever used
				// in the above method?
				return false;
			}
			else
			{
				return entry.ExistsInDatabase;
			}
		}
开发者ID:ray2006,项目名称:WCell,代码行数:25,代码来源:DefaultMergeEventListener.cs

示例4: GetUpdateId

		/// <summary> Determine the id to use for updating. </summary>
		/// <param name="entity">The entity. </param>
		/// <param name="persister">The entity persister </param>
		/// <param name="requestedId">The requested identifier </param>
		/// <param name="entityMode">The entity mode. </param>
		/// <returns> The id. </returns>
		protected virtual object GetUpdateId(object entity, IEntityPersister persister, object requestedId, EntityMode entityMode)
		{
			// use the id assigned to the instance
			object id = persister.GetIdentifier(entity, entityMode);
			if (id == null)
			{
				// assume this is a newly instantiated transient object
				// which should be saved rather than updated
				throw new TransientObjectException("The given object has a null identifier: " + persister.EntityName);
			}
			else
			{
				return id;
			}
		}
开发者ID:Ruhollah,项目名称:nhibernate-core,代码行数:21,代码来源:DefaultSaveOrUpdateEventListener.cs

示例5: GetIdentifier

		public static object GetIdentifier(object obj, IEntityPersister persister)
		{
			if (obj is INHibernateProxy)
			{
				INHibernateProxy proxy = (INHibernateProxy) obj;
				LazyInitializer li = GetLazyInitializer(proxy);
				return li.Identifier;
			}
			else
			{
				return persister.GetIdentifier(obj);
			}
		}
开发者ID:Novthirteen,项目名称:sconit_timesseiko,代码行数:13,代码来源:NHibernateProxyHelper.cs


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