public void RaiseInvalidate(QuerySetStorageKey key) { this.Invalidate( this, new QuerySetStorageInvalidateEventArgs(key) ); }
public void Set(QuerySetStorageKey key, IModel o) { if (cache.Count >= MAX_ENTRIES) { foreach (QuerySetStorageKey k in cache.Keys) { cache.Remove(k); this.RaiseInvalidate(k); break; } } cache[key] = o; this.RaiseInvalidate(key); }
public IModel Get(QuerySetStorageKey key) { return cache[key]; }
public void Delete(QuerySetStorageKey key) { cache.Remove(key); }
public bool Equals(QuerySetStorageKey other) { return this.GetHashCode() == other.GetHashCode(); }
public QuerySetStorageInvalidateEventArgs(QuerySetStorageKey key) { this.Key = key; }
public IEnumerator<IModel> GetEnumerator() { Connections.IConnection conn = new Connections.Connection(); object[][] res = conn.Execute(this.query); IModel o; Dictionary<string, object> dict; QuerySetStorageKey storage_key; foreach (object[] row in res) { // need to instantiate a model here, to get the ModelMeta o = (IModel)(Activator.CreateInstance(this.query.Model)); storage_key = new QuerySetStorageKey( this.query.Model, row[o.Meta.GetFieldIndex(o.Meta.PrimaryKey.DbField)] ); try { o = storage.Get(storage_key); } catch (KeyNotFoundException) { dict = o.Meta.PrepareRowForInstance(row); foreach (string key in dict.Keys) { o.Set(key, dict[key]); } this.storage.Set(storage_key, o); } yield return o; } }