本文整理汇总了C#中IEntity.PreStore方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.PreStore方法的具体用法?C# IEntity.PreStore怎么用?C# IEntity.PreStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntity
的用法示例。
在下文中一共展示了IEntity.PreStore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PreSave
/// <summary>
/// Prepares the provided entity for saving.
/// </summary>
/// <param name="entity">The entity to prepare for saving.</param>
/// <param name="handleReferences">A value indicating whether to delete old references and save new references.</param>
public override void PreSave(IEntity entity, bool handleReferences)
{
using (LogGroup logGroup = LogGroup.StartDebug("Preparing entity for saving: " + entity.GetType().ToString()))
{
if (entity == null)
throw new ArgumentNullException("entity");
entity.PreStore();
// If the entity is NOT a reference object (ie. it's a standard entity)
// then prepare the save.
// If is IS a reference object the preparation is not needed and should be skipped
if (!(entity is EntityReference))
{
Type entityType = entity.GetType();
LogWriter.Debug("Entity type: " + entityType.ToString());
if (handleReferences)
{
// Maintain the entity references
Provider.Referencer.MaintainReferences(entity);
}
LogWriter.Debug("Presave complete.");
}
}
}
示例2: PreUpdate
/// <summary>
/// Prepares the provided entity to be updated and handles references.
/// </summary>
/// <param name="entity">The entity to be prepared for update.</param>
public override void PreUpdate(IEntity entity)
{
using (LogGroup logGroup = LogGroup.Start("Preparing entity to be updated.", NLog.LogLevel.Debug))
{
if (entity == null)
throw new ArgumentNullException("entity");
LogWriter.Debug("Entity type: " + entity.GetType().ToString());
LogWriter.Debug("Entity ID : " + entity.ID);
entity.PreStore();
// If the entity is NOT a reference object (ie. it's a standard entity)
// then prepare the update.
// If it IS a reference object the preparation is not needed and should be skipped
if (!(entity is EntityReference))
{
Provider.Referencer.MaintainReferences(entity);
}
}
}