src/Shared/EntityFramework/Core/Objects/ObjectParameterCollection.cs
// <summary>
// Retrieves a string that may be used to represent this parameter collection in an ObjectQuery cache key.
// If this collection has not changed since the last call to this method, the same string instance is returned.
// Note that this string is used by various ObjectQueryImplementations to version the parameter collection.
// </summary>
// <returns> A string that may be used to represent this parameter collection in an ObjectQuery cache key. </returns>
Retrieves a string that may be used to represent this parameter collection in an ObjectQuery cache key.
If this collection has not changed since the last call to this method, the same string instance is returned.
Note that this string is used by various ObjectQueryImplementations to version the parameter collection.
Retrieves a string that may be used to represent this parameter collection in an ObjectQuery cache key . If this collection has not changed since the last call to this method the same string instance is returned . Note that this string is used by various ObjectQueryImplementations to version the parameter collection .
internal string GetCacheKey()
        {
            if (null == _cacheKey)
            {
                if (_parameters.Count > 0)
                {
                    if (1 == _parameters.Count)
                    {
                        var theParam = _parameters[0];
                        _cacheKey = "@@1" + theParam.Name + ":" + theParam.ParameterType.FullName;
                    }
                    else
                    {
                        var keyBuilder = new StringBuilder(_parameters.Count * 20);
                        keyBuilder.Append("@@");
                        keyBuilder.Append(_parameters.Count);
                        for (var idx = 0; idx < _parameters.Count; idx++)
                        {
                             CONSIDER adding other parameter properties
                            if (idx > 0)
                            {
                                keyBuilder.Append(";");
                            }
                            var thisParam = _parameters[idx];
                            keyBuilder.Append(thisParam.Name);
                            keyBuilder.Append(":");
                            keyBuilder.Append(thisParam.ParameterType.FullName);
                        }
                        _cacheKey = keyBuilder.ToString();
                    }
                }
            }
            return _cacheKey;
        }
internal string GetCacheKey ( ) { if ( null == _cacheKey ) { if ( _parameters . Count > 0 ) { if ( 1 == _parameters . Count ) { var theParam = _parameters [ 0 ] ; _cacheKey = " " + theParam . Name + " " + theParam . ParameterType . FullName ; } else { var keyBuilder = new StringBuilder ( _parameters . Count * 20 ) ; keyBuilder . Append ( " " ) ; keyBuilder . Append ( _parameters . Count ) ; for ( var idx = 0 ; idx < _parameters . Count ; idx ++ ) { if ( idx > 0 ) { keyBuilder . Append ( " " ) ; } var thisParam = _parameters [ idx ] ; keyBuilder . Append ( thisParam . Name ) ; keyBuilder . Append ( " " ) ; keyBuilder . Append ( thisParam . ParameterType . FullName ) ; } _cacheKey = keyBuilder . ToString ( ) ; } } } return _cacheKey ; }
Retrieves a string that may be used to represent this parameter collection in an ObjectQuery cache key.
Retrieves a string that may be used to represent this parameter collection in an ObjectQuery cache key .
// Future Enhancement: If the separate branch for a single parameter does not have a measurable perf advantage, remove it. // if its one parameter only, there is no need to use stringbuilder // Future Enhancement: Investigate whether precalculating the required size of the string builder is a better time/space tradeoff. // // CONSIDER adding other parameter properties //
A string that may be used to represent this parameter collection in an ObjectQuery cache key.
A string that may be used to represent this parameter collection in an ObjectQuery cache key .