From 1df947bdf86cdc136beed59e0f9f380ac35faf64 Mon Sep 17 00:00:00 2001 From: Rich Date: Mon, 5 Nov 2012 22:02:57 +0000 Subject: [PATCH] Restored logic to check cache so that the same item is not added repeatedly Eliminate AddToCache in the factory constructor. This was causing the same item to be added to the cache repeatedly. --- .../Generated/ItemInfo.cs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs index e0c534ee..85c3446c 100644 --- a/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs +++ b/PROMS/VEPROMS.CSLA.Library/Generated/ItemInfo.cs @@ -39,22 +39,23 @@ namespace VEPROMS.CSLA.Library private static List _CacheList = new List(); protected static void AddToCache(ItemInfo itemInfo) { - //if (!_CacheList.Contains(itemInfo)) - try - { + if (!_CacheList.Contains(itemInfo)) _CacheList.Add(itemInfo); // In AddToCache - } - catch (Exception ex) - { - _MyLog.ErrorFormat("ItemInfo {0}.{1} already exists in the cache", itemInfo.ItemID,itemInfo.MyItemInfoUnique); - } + //try + //{ + // _CacheList.Add(itemInfo); // In AddToCache + //} + //catch (Exception ex) + //{ + // _MyLog.ErrorFormat("ItemInfo {0}.{1} already exists in the cache", itemInfo.ItemID, itemInfo.MyItemInfoUnique); + //} } protected static void RemoveFromCache(ItemInfo itemInfo) { while (_CacheList.Contains(itemInfo)) _CacheList.Remove(itemInfo); // In RemoveFromCache } - private static Dictionary> _CacheByPrimaryKey = new Dictionary>(); - private static void ConvertListToDictionary() + protected static Dictionary> _CacheByPrimaryKey = new Dictionary>(); + protected static void ConvertListToDictionary() { while (_CacheList.Count > 0) // Move ItemInfo(s) from temporary _CacheList to _CacheByPrimaryKey { @@ -428,7 +429,7 @@ namespace VEPROMS.CSLA.Library { get { return _MyItemInfoUnique; } } protected ItemInfo() {/* require use of factory methods */ - AddToCache(this); + //AddToCache(this); } private bool _Disposed = false; private static int _CountCreated = 0; @@ -578,7 +579,7 @@ namespace VEPROMS.CSLA.Library _ItemID = itemID; } } - private void ReadData(SafeDataReader dr) + protected void ReadData(SafeDataReader dr) { if (_MyLog.IsDebugEnabled) _MyLog.DebugFormat("[{0}] ItemInfo.ReadData", GetHashCode()); try