本文整理汇总了C#中NHibernate.Collection.List.Concat方法的典型用法代码示例。如果您正苦于以下问题:C# List.Concat方法的具体用法?C# List.Concat怎么用?C# List.Concat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Collection.List
的用法示例。
在下文中一共展示了List.Concat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Dispatch
public override IAuditWorkUnit Dispatch(IWorkUnitMergeVisitor first)
{
if (first is PersistentCollectionChangeWorkUnit) {
PersistentCollectionChangeWorkUnit original = (PersistentCollectionChangeWorkUnit) first;
// Merging the collection changes in both work units.
// First building a map from the ids of the collection-entry-entities from the "second" collection changes,
// to the PCCD objects. That way, we will be later able to check if an "original" collection change
// should be added, or if it is overshadowed by a new one.
IDictionary<Object, PersistentCollectionChangeData> newChangesIdMap = new Dictionary<Object, PersistentCollectionChangeData>();
foreach (PersistentCollectionChangeData persistentCollectionChangeData in getCollectionChanges()) {
newChangesIdMap.Add(
getOriginalId(persistentCollectionChangeData),
persistentCollectionChangeData);
}
// This will be the list with the resulting (merged) changes.
List<PersistentCollectionChangeData> mergedChanges = new List<PersistentCollectionChangeData>();
// Including only those original changes, which are not overshadowed by new ones.
foreach (PersistentCollectionChangeData originalCollectionChangeData in original.getCollectionChanges()) {
if (!newChangesIdMap.ContainsKey(getOriginalId(originalCollectionChangeData))) {
mergedChanges.Add(originalCollectionChangeData);
}
}
// Finally adding all of the new changes to the end of the list
mergedChanges = (List<PersistentCollectionChangeData>)mergedChanges.Concat(getCollectionChanges());
return new PersistentCollectionChangeWorkUnit(sessionImplementor, EntityName, verCfg, EntityId, mergedChanges,
ReferencingPropertyName);
} else {
throw new Exception("Trying to merge a " + first + " with a PersitentCollectionChangeWorkUnit. " +
"This is not really possible.");
}
}
示例2: Dispatch
public override IAuditWorkUnit Dispatch(IWorkUnitMergeVisitor first)
{
var original = first as PersistentCollectionChangeWorkUnit;
if (original != null)
{
// Merging the collection changes in both work units.
// First building a map from the ids of the collection-entry-entities from the "second" collection changes,
// to the PCCD objects. That way, we will be later able to check if an "original" collection change
// should be added, or if it is overshadowed by a new one.
var newChangesIdMap = new Dictionary<IDictionary<string, object>, PersistentCollectionChangeData>(new DictionaryComparer<string, object>());
foreach (var persistentCollectionChangeData in CollectionChanges)
{
newChangesIdMap.Add(
OriginalId(persistentCollectionChangeData),
persistentCollectionChangeData);
}
// This will be the list with the resulting (merged) changes.
var mergedChanges = new List<PersistentCollectionChangeData>();
// Including only those original changes, which are not overshadowed by new ones.
foreach (var originalCollectionChangeData in original.CollectionChanges)
{
var originalOriginalId = OriginalId(originalCollectionChangeData);
if (!newChangesIdMap.ContainsKey(originalOriginalId))
{
mergedChanges.Add(originalCollectionChangeData);
}
else
{
// If the changes collide, checking if the first one isn't a DEL, and the second a subsequent ADD
// If so, removing the change alltogether.
var revTypePropName = VerCfg.AuditEntCfg.RevisionTypePropName;
if((RevisionType)newChangesIdMap[originalOriginalId].Data[revTypePropName] == RevisionType.Added &&
(RevisionType)originalCollectionChangeData.Data[revTypePropName] == RevisionType.Deleted)
{
newChangesIdMap.Remove(originalOriginalId);
}
}
}
// Finally adding all of the new changes to the end of the list
// (the map values may differ from CollectionChanges because of the last operation above)
mergedChanges = mergedChanges.Concat(newChangesIdMap.Values).ToList();
return new PersistentCollectionChangeWorkUnit(SessionImplementor, EntityName, VerCfg, EntityId, mergedChanges,
referencingPropertyName);
}
throw new Exception("Trying to merge a " + first + " with a PersitentCollectionChangeWorkUnit. " +
"This is not really possible.");
}