本文整理汇总了C#中IEntityPersister.SetPropertyValues方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityPersister.SetPropertyValues方法的具体用法?C# IEntityPersister.SetPropertyValues怎么用?C# IEntityPersister.SetPropertyValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntityPersister
的用法示例。
在下文中一共展示了IEntityPersister.SetPropertyValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Process
internal override void Process(object obj, IEntityPersister persister)
{
EntityMode entityMode = Session.EntityMode;
object[] values = persister.GetPropertyValues(obj, entityMode);
IType[] types = persister.PropertyTypes;
ProcessEntityPropertyValues(values, types);
if (SubstitutionRequired)
{
persister.SetPropertyValues(obj, values, entityMode);
}
}
示例2: Assemble
private static object[] Assemble(object[] values, object result, object id, IEntityPersister persister,
IInterceptor interceptor, ISessionImplementor session)
{
IType[] propertyTypes = persister.PropertyTypes;
object[] assembledProps = new object[propertyTypes.Length];
for (int i = 0; i < values.Length; i++)
{
assembledProps[i] = propertyTypes[i].Assemble(values[i], session, result);
}
interceptor.OnLoad(result, id, assembledProps, persister.PropertyNames, propertyTypes);
persister.SetPropertyValues(result, assembledProps);
if (persister.ImplementsLifecycle)
{
((ILifecycle) result).OnLoad(session, id);
}
return assembledProps;
}
示例3: PerformSaveOrReplicate
/// <summary>
/// Performs all the actual work needed to save an entity (well to get the save moved to
/// the execution queue).
/// </summary>
/// <param name="entity">The entity to be saved </param>
/// <param name="key">The id to be used for saving the entity (or null, in the case of identity columns) </param>
/// <param name="persister">The entity's persister instance. </param>
/// <param name="useIdentityColumn">Should an identity column be used for id generation? </param>
/// <param name="anything">Generally cascade-specific information. </param>
/// <param name="source">The session which is the source of the current event. </param>
/// <param name="requiresImmediateIdAccess">
/// Is access to the identifier required immediately
/// after the completion of the save? persist(), for example, does not require this...
/// </param>
/// <returns>
/// The id used to save the entity; may be null depending on the
/// type of id generator used and the requiresImmediateIdAccess value
/// </returns>
protected virtual object PerformSaveOrReplicate(object entity, EntityKey key, IEntityPersister persister, bool useIdentityColumn, object anything, IEventSource source, bool requiresImmediateIdAccess)
{
Validate(entity, persister, source);
object id = key == null ? null : key.Identifier;
// NH Different behavior (shouldDelayIdentityInserts=false anyway)
//bool inTxn = source.ConnectionManager.IsInActiveTransaction;
//bool shouldDelayIdentityInserts = !inTxn && !requiresImmediateIdAccess;
bool shouldDelayIdentityInserts = false;
// Put a placeholder in entries, so we don't recurse back and try to save() the
// same object again. QUESTION: should this be done before onSave() is called?
// likewise, should it be done before onUpdate()?
source.PersistenceContext.AddEntry(entity, Status.Saving, null, null, id, null, LockMode.Write, useIdentityColumn, persister, false, false);
CascadeBeforeSave(source, persister, entity, anything);
// NH-962: This was originally done before many-to-one cascades.
if (useIdentityColumn && !shouldDelayIdentityInserts)
{
log.Debug("executing insertions");
source.ActionQueue.ExecuteInserts();
}
object[] values = persister.GetPropertyValuesToInsert(entity, GetMergeMap(anything), source);
IType[] types = persister.PropertyTypes;
bool substitute = SubstituteValuesIfNecessary(entity, id, values, persister, source);
if (persister.HasCollections)
{
substitute = substitute || VisitCollectionsBeforeSave(entity, id, values, types, source);
}
if (substitute)
{
persister.SetPropertyValues(entity, values, source.EntityMode);
}
TypeHelper.DeepCopy(values, types, persister.PropertyUpdateability, values, source);
new ForeignKeys.Nullifier(entity, false, useIdentityColumn, source).NullifyTransientReferences(values, types);
new Nullability(source).CheckNullability(values, persister, false);
if (useIdentityColumn)
{
EntityIdentityInsertAction insert = new EntityIdentityInsertAction(values, entity, persister, source, shouldDelayIdentityInserts);
if (!shouldDelayIdentityInserts)
{
log.Debug("executing identity-insert immediately");
source.ActionQueue.Execute(insert);
id = insert.GeneratedId;
//now done in EntityIdentityInsertAction
//persister.setIdentifier( entity, id, source.getEntityMode() );
key = source.GenerateEntityKey(id, persister);
source.PersistenceContext.CheckUniqueness(key, entity);
//source.getBatcher().executeBatch(); //found another way to ensure that all batched joined inserts have been executed
}
else
{
log.Debug("delaying identity-insert due to no transaction in progress");
source.ActionQueue.AddAction(insert);
key = insert.DelayedEntityKey;
}
}
object version = Versioning.GetVersion(values, persister);
source.PersistenceContext.AddEntity(
entity,
persister.IsMutable ? Status.Loaded : Status.ReadOnly,
values, key,
version,
LockMode.Write,
useIdentityColumn,
persister,
VersionIncrementDisabled,
false);
//source.getPersistenceContext().removeNonExist( new EntityKey( id, persister, source.getEntityMode() ) );
if (!useIdentityColumn)
{
//.........这里部分代码省略.........
示例4: CopyValues
protected virtual void CopyValues(IEntityPersister persister, object entity, object target,
ISessionImplementor source, IDictionary copyCache, ForeignKeyDirection foreignKeyDirection)
{
object[] copiedValues;
if (foreignKeyDirection == ForeignKeyDirection.ForeignKeyToParent)
{
// this is the second pass through on a merge op, so here we limit the
// replacement to associations types (value types were already replaced
// during the first pass)
copiedValues =
TypeFactory.ReplaceAssociations(persister.GetPropertyValues(entity, source.EntityMode),
persister.GetPropertyValues(target, source.EntityMode), persister.PropertyTypes,
source, target, copyCache, foreignKeyDirection);
}
else
{
copiedValues =
TypeFactory.Replace(persister.GetPropertyValues(entity, source.EntityMode),
persister.GetPropertyValues(target, source.EntityMode), persister.PropertyTypes, source, target,
copyCache, foreignKeyDirection);
}
persister.SetPropertyValues(target, copiedValues, source.EntityMode);
}
示例5: Process
public override void Process(object obj, IEntityPersister persister)
{
object[] values = persister.GetPropertyValues(obj);
IType[] types = persister.PropertyTypes;
ProcessValues(values, types);
if (IsSubstitutionRequired)
{
persister.SetPropertyValues(obj, values);
}
}
示例6: Assemble
private static object[] Assemble(object[] values, object result, object id, IEntityPersister persister,
IInterceptor interceptor, ISessionImplementor session)
{
//assembled state gets put in a new array (we read from cache by value!)
object[] assembledProps = TypeFactory.Assemble(values, persister.PropertyTypes, session, result);
//from h3.2 TODO: reuse the PreLoadEvent
PreLoadEvent preLoadEvent = new PreLoadEvent((IEventSource) session);
preLoadEvent.Entity = result;
preLoadEvent.State=assembledProps;
preLoadEvent.Id = id;
preLoadEvent.Persister=persister;
IPreLoadEventListener[] listeners = session.Listeners.PreLoadEventListeners;
for (int i = 0; i < listeners.Length; i++)
{
listeners[i].OnPreLoad(preLoadEvent);
}
persister.SetPropertyValues(result, assembledProps, session.EntityMode);
return assembledProps;
}