本文整理汇总了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 );
}
}
}
示例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);
}
}
示例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;
}
示例4: Id
private object Id( object component, ISessionImplementor session )
{
try
{
return session.GetEntityIdentifierIfNotUnsaved( component );
}
catch( TransientObjectException )
{
return null;
}
}
示例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
}
示例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);
}
}
示例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
);
}
}
示例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);
}
}