示例#1
0
 /// <summary>
 /// Add object to the Cache
 /// </summary>
 /// <param name="key">Key of thee object</param>
 /// <param name="Id">Object Id if available then key will be key plus Id</param>
 /// <param name="data">value</param>
 protected void AddToCache(string key, int Id, object data)
 {
     if (Id > 0)
     {
         CachedData.Add(key + "-" + Id, data);
     }
     else
     {
         CachedData.Add(key, data);
     }
 }
示例#2
0
        protected void Cache()
        {
            PropertyInfo p = this.GetType().GetProperty("ID");

            if (p == null)
            {
                throw new InvalidOperationException("Can't use this version of Cache() with no public ID property");
            }
            int val = Convert.ToInt32(p.GetValue(this, null));

            if (val <= 0)
            {
                throw new InvalidOperationException("Can't cache Business objects that have not been persisted to the store");
            }
            string key = this.GetType().ToString() + Convert.ToString(val);

            CachedData.Add(key, this);
        }
示例#3
0
        protected void Cache(object key)
        {
            string val = this.GetType().ToString() + Convert.ToString(key);

            CachedData.Add(val, this);
        }