/// <summary> /// get cache keys /// </summary> /// <param name="keyAndValues">key and values</param> /// <param name="includeObjectName">whether include object name</param> /// <returns></returns> public static string GetCacheKey(IDictionary <string, dynamic> keyAndValues, bool includeObjectName = true) { List <string> keys = new List <string>(); if (includeObjectName) { Type type = typeof(T); string objectName = EntityManager.GetEntityObjectName(type); if (!string.IsNullOrWhiteSpace(objectName)) { keys.Add(objectName); } } if (keyAndValues != null && keyAndValues.Count > 0) { SortedDictionary <string, dynamic> sortedValues = new SortedDictionary <string, dynamic>(); foreach (var valItem in keyAndValues) { sortedValues.Add(valItem.Key, valItem.Value); } foreach (var sortValItem in sortedValues) { keys.Add(string.Format("{0}${1}", sortValItem.Key, sortValItem.Value)); } } return(string.Join(":", keys)); }
/// <summary> /// generate cache key /// </summary> /// <param name="keys">keys</param> /// <param name="includeObjectName">whether include object name</param> /// <returns></returns> string GenerateCacheKey(IEnumerable <EntityField> keys, bool includeObjectName = true) { List <string> keyValues = new List <string>(); var type = typeof(T); if (includeObjectName) { string objectName = EntityManager.GetEntityObjectName(type); if (!string.IsNullOrWhiteSpace(objectName)) { keyValues.Add(objectName); } } if (keys != null) { foreach (string key in keys) { keyValues.Add(string.Format("{0}${1}", key, valueDict[key])); } } return(string.Join(":", keyValues)); }
/// <summary> /// get object name /// </summary> /// <returns></returns> public static string GetObjectName() { Type type = typeof(T); return(EntityManager.GetEntityObjectName(type)); }