/// <summary> /// /// </summary> /// <param name="keyValue"></param> /// <param name="forceRefresh"></param> /// <param name="createCache"></param> /// <returns></returns> public T FindById(object keyValue, bool forceRefresh = false, bool createCache = true) { T data = null; var cacheKey = string.Format(Config.CacheKey, keyValue) + typeof(T); var obj = Cache.Get <T>(cacheKey); if (obj == null || forceRefresh) { var trans = new Transaction(); try { trans.Begin(); var dbHelper = new MssqlHelper <T>(); data = dbHelper.FindById(keyValue, trans.DbConnection, trans.DbTrans); trans.Commit(); } catch (Exception ex) { trans.RollBack(); Logger.Error(ex); } finally { trans.Dispose(); } if (data != null && createCache) { Cache.Insert(cacheKey, data); } } else { data = obj; } return(data); }