Exemple #1
0
        public static T Cache <T, TKey>(this SimpleMRUCache cache, TKey key, Func <TKey, T> @select)
        {
            var cached = (T)cache[key];

            if (!Equals(cached, default(T)))
            {
                return(cached);
            }
            cached = @select(key);
            cache.Put(key, cached);
            return(cached);
        }
        public ParameterMetadata GetSQLParameterMetadata(string query)
        {
            var metadata = (ParameterMetadata)sqlParamMetadataCache[query];

            if (metadata == null)
            {
                // for native-sql queries, the param metadata is determined outside
                // any relation to a query plan, because query plan creation and/or
                // retrieval for a native-sql query depends on all of the return
                // types having been set, which might not be the case up-front when
                // param metadata would be most useful
                metadata = BuildNativeSQLParameterMetadata(query);
                sqlParamMetadataCache.Put(query, metadata);
            }
            return(metadata);
        }