本文整理汇总了C#中ISessionImplementor.GetEntry方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionImplementor.GetEntry方法的具体用法?C# ISessionImplementor.GetEntry怎么用?C# ISessionImplementor.GetEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISessionImplementor
的用法示例。
在下文中一共展示了ISessionImplementor.GetEntry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete
public void Delete(object id, object version, object obj, ISessionImplementor session)
{
int span = TableSpan;
bool isImpliedOptimisticLocking = !entityMetamodel.IsVersioned &&
entityMetamodel.OptimisticLockMode > OptimisticLockMode.Version;
object[] loadedState = null;
if (isImpliedOptimisticLocking)
{
// need to treat this as if it where optimistic-lock="all" (dirty does *not* make sense);
// first we need to locate the "loaded" state
//
// Note, it potentially could be a proxy, so perform the location the safe way...
EntityKey key = new EntityKey(id, this);
object entity = session.GetEntity(key);
if (entity != null)
{
EntityEntry entry = session.GetEntry(entity);
loadedState = entry.LoadedState;
}
}
SqlCommandInfo[] deleteStrings;
if (isImpliedOptimisticLocking && loadedState != null)
{
// we need to utilize dynamic delete statements
deleteStrings = GenerateDeleteStrings(loadedState);
}
else
{
// otherwise, utilize the static delete statements
deleteStrings = SqlDeleteStrings;
}
for (int j = span - 1; j >= 0; j--)
{
Delete(id, version, j, obj, deleteStrings[j], session, loadedState);
}
}
示例2: GetKeyOfOwner
/// <summary>
/// Get the key value from the owning entity instance, usually the identifier, but might be some
/// other unique key, in the case of property-ref
/// </summary>
public object GetKeyOfOwner(object owner, ISessionImplementor session)
{
EntityEntry entityEntry = session.GetEntry(owner);
if (entityEntry == null)
{
// This just handles a particular case of component
// projection, perhaps get rid of it and throw an exception
return null;
}
if (foreignKeyPropertyName == null)
{
return entityEntry.Id;
}
else
{
// TODO: at the point where we are resolving collection references, we don't
// know if the uk value has been resolved (depends if it was earlier or
// later in the mapping document) - now, we could try and use e.getStatus()
// to decide to semiResolve(), trouble is that initializeEntity() reuses
// the same array for resolved and hydrated values
object id = entityEntry.GetLoadedValue(foreignKeyPropertyName);
// NOTE VERY HACKISH WORKAROUND!!
IType keyType = GetPersister(session).KeyType;
if (!keyType.ReturnedClass.IsInstanceOfType(id))
{
id = keyType.SemiResolve(
entityEntry.GetLoadedValue(foreignKeyPropertyName),
session,
owner
);
}
return id;
}
}