本文整理汇总了C#中ISessionImplementor.GetEntity方法的典型用法代码示例。如果您正苦于以下问题:C# ISessionImplementor.GetEntity方法的具体用法?C# ISessionImplementor.GetEntity怎么用?C# ISessionImplementor.GetEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISessionImplementor
的用法示例。
在下文中一共展示了ISessionImplementor.GetEntity方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: GetImplementation
/// <summary>
/// Return the Underlying Persistent Object in a given <see cref="ISession"/>, or null.
/// </summary>
/// <param name="s">The Session to get the object from.</param>
/// <returns>The Persistent Object this proxy is Proxying, or <see langword="null" />.</returns>
public object GetImplementation(ISessionImplementor s)
{
EntityKey key = new EntityKey(Identifier, s.Factory.GetEntityPersister(PersistentClass));
return s.GetEntity(key);
}
示例3: GetRow
/// <summary>
/// Resolve any ids for currently loaded objects, duplications within the <c>IDataReader</c>,
/// etc. Instanciate empty objects to be initialized from the <c>IDataReader</c>. Return an
/// array of objects (a row of results) and an array of booleans (by side-effect) that determine
/// wheter the corresponding object should be initialized
/// </summary>
/// <param name="rs"></param>
/// <param name="persisters"></param>
/// <param name="suffixes"></param>
/// <param name="keys"></param>
/// <param name="optionalObject"></param>
/// <param name="optionalObjectKey"></param>
/// <param name="session"></param>
/// <param name="hydratedObjects"></param>
/// <param name="lockModes"></param>
/// <returns></returns>
private object[ ] GetRow(
IDataReader rs,
ILoadable[ ] persisters,
string[ ] suffixes,
Key[ ] keys,
object optionalObject,
Key optionalObjectKey,
LockMode[ ] lockModes,
IList hydratedObjects,
ISessionImplementor session )
{
int cols = persisters.Length;
if( log.IsDebugEnabled )
{
log.Debug( "result row: " + StringHelper.ToString( keys ) );
}
object[ ] rowResults = new object[cols];
for( int i = 0; i < cols; i++ )
{
object obj = null;
Key key = keys[ i ];
if( keys[ i ] == null )
{
// do nothing
}
else
{
//If the object is already loaded, return the loaded one
obj = session.GetEntity( key );
if( obj != null )
{
//its already loaded so dont need to hydrate it
InstanceAlreadyLoaded( rs, i, persisters[ i ], suffixes[ i ], key, obj, lockModes[ i ], session );
}
else
{
obj = InstanceNotYetLoaded( rs, i, persisters[ i ], suffixes[ i ], key, lockModes[ i ], optionalObjectKey, optionalObject, hydratedObjects, session );
}
}
rowResults[ i ] = obj;
}
return rowResults;
}