Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataEntity / System / Data / Common / QueryCache / EntitySqlQueryCacheKey.cs / 1 / EntitySqlQueryCacheKey.cs
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//-----------------------------------------------------------------------------
namespace System.Data.Common.QueryCache
{
using System;
using System.Data.Objects;
using System.Diagnostics;
///
/// Represents an Entity-SQL-based ObjectQuery Cache key context
///
internal sealed class EntitySqlQueryCacheKey : QueryCacheKey
{
///
/// Aggregate hashcode based the hashcode of the properties of this cache key
///
private readonly int _hashCode;
///
/// The name of the default container in effect when the Entity-SQL text was parsed
/// (affects whether or not the text can be successfully parsed)
///
private string _defaultContainer;
///
/// Entity Sql statement
///
private readonly string _eSqlStatement;
///
/// Parameter collection token
///
private readonly string _parametersToken;
///
/// Number of parameters
///
private readonly int _parameterCount;
///
/// Concatenated representation of the Include span paths
///
private readonly string _includePathsToken;
///
/// The merge option in effect
///
private readonly MergeOption _mergeOption;
///
/// Result type affects assembly plan.
///
private readonly Type _resultType;
///
/// Creates a new instance of ObjectQueryCacheKey given a entityCommand instance
///
/// The default container name in effect when parsing the query (may be null)
/// The Entity-SQL text of the query
/// The number of parameters to the query
/// A string representation of the parameters to the query (may be null)
/// A string representation of the Include span paths in effect (may be null)
/// The merge option in effect. Required for result assembly.
internal EntitySqlQueryCacheKey(string defaultContainerName,
string eSqlStatement,
int parameterCount,
string parametersToken,
string includePathsToken,
MergeOption mergeOption,
Type resultType)
: base()
{
Debug.Assert(null != eSqlStatement, "eSqlStatement must not be null");
_defaultContainer = defaultContainerName;
_eSqlStatement = eSqlStatement;
_parameterCount = parameterCount;
_parametersToken = parametersToken;
_includePathsToken = includePathsToken;
_mergeOption = mergeOption;
_resultType = resultType;
int combinedHash = _eSqlStatement.GetHashCode() ^
_mergeOption.GetHashCode();
if (_parametersToken != null)
{
combinedHash ^= _parametersToken.GetHashCode();
}
if (_includePathsToken != null)
{
combinedHash ^= _includePathsToken.GetHashCode();
}
if (_defaultContainer != null)
{
combinedHash ^= _defaultContainer.GetHashCode();
}
_hashCode = combinedHash;
}
///
/// Determines equality of two cache keys based on cache context values
///
///
///
public override bool Equals(object otherObject)
{
Debug.Assert(null != otherObject, "otherObject must not be null");
if (typeof(EntitySqlQueryCacheKey) != otherObject.GetType())
{
return false;
}
EntitySqlQueryCacheKey otherObjectQueryCacheKey = (EntitySqlQueryCacheKey)otherObject;
// also use result type...
return (_parameterCount == otherObjectQueryCacheKey._parameterCount) &&
(_mergeOption == otherObjectQueryCacheKey._mergeOption) &&
Equals(otherObjectQueryCacheKey._defaultContainer, _defaultContainer) &&
Equals(otherObjectQueryCacheKey._eSqlStatement, _eSqlStatement) &&
Equals(otherObjectQueryCacheKey._includePathsToken, _includePathsToken) &&
Equals(otherObjectQueryCacheKey._parametersToken, _parametersToken) &&
Equals(otherObjectQueryCacheKey._resultType, _resultType);
}
///
/// Returns the hashcode for this cache key
///
///
public override int GetHashCode()
{
return _hashCode;
}
///
/// Returns a string representation of the state of this cache key
///
///
/// A string representation that includes query text, parameter information, include path information
/// and merge option information about this cache key.
///
public override string ToString()
{
return String.Join("|", new string[] { _defaultContainer, _eSqlStatement, _parametersToken, _includePathsToken, Enum.GetName(typeof(MergeOption), _mergeOption) });
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....], [....]
//-----------------------------------------------------------------------------
namespace System.Data.Common.QueryCache
{
using System;
using System.Data.Objects;
using System.Diagnostics;
///
/// Represents an Entity-SQL-based ObjectQuery Cache key context
///
internal sealed class EntitySqlQueryCacheKey : QueryCacheKey
{
///
/// Aggregate hashcode based the hashcode of the properties of this cache key
///
private readonly int _hashCode;
///
/// The name of the default container in effect when the Entity-SQL text was parsed
/// (affects whether or not the text can be successfully parsed)
///
private string _defaultContainer;
///
/// Entity Sql statement
///
private readonly string _eSqlStatement;
///
/// Parameter collection token
///
private readonly string _parametersToken;
///
/// Number of parameters
///
private readonly int _parameterCount;
///
/// Concatenated representation of the Include span paths
///
private readonly string _includePathsToken;
///
/// The merge option in effect
///
private readonly MergeOption _mergeOption;
///
/// Result type affects assembly plan.
///
private readonly Type _resultType;
///
/// Creates a new instance of ObjectQueryCacheKey given a entityCommand instance
///
/// The default container name in effect when parsing the query (may be null)
/// The Entity-SQL text of the query
/// The number of parameters to the query
/// A string representation of the parameters to the query (may be null)
/// A string representation of the Include span paths in effect (may be null)
/// The merge option in effect. Required for result assembly.
internal EntitySqlQueryCacheKey(string defaultContainerName,
string eSqlStatement,
int parameterCount,
string parametersToken,
string includePathsToken,
MergeOption mergeOption,
Type resultType)
: base()
{
Debug.Assert(null != eSqlStatement, "eSqlStatement must not be null");
_defaultContainer = defaultContainerName;
_eSqlStatement = eSqlStatement;
_parameterCount = parameterCount;
_parametersToken = parametersToken;
_includePathsToken = includePathsToken;
_mergeOption = mergeOption;
_resultType = resultType;
int combinedHash = _eSqlStatement.GetHashCode() ^
_mergeOption.GetHashCode();
if (_parametersToken != null)
{
combinedHash ^= _parametersToken.GetHashCode();
}
if (_includePathsToken != null)
{
combinedHash ^= _includePathsToken.GetHashCode();
}
if (_defaultContainer != null)
{
combinedHash ^= _defaultContainer.GetHashCode();
}
_hashCode = combinedHash;
}
///
/// Determines equality of two cache keys based on cache context values
///
///
///
public override bool Equals(object otherObject)
{
Debug.Assert(null != otherObject, "otherObject must not be null");
if (typeof(EntitySqlQueryCacheKey) != otherObject.GetType())
{
return false;
}
EntitySqlQueryCacheKey otherObjectQueryCacheKey = (EntitySqlQueryCacheKey)otherObject;
// also use result type...
return (_parameterCount == otherObjectQueryCacheKey._parameterCount) &&
(_mergeOption == otherObjectQueryCacheKey._mergeOption) &&
Equals(otherObjectQueryCacheKey._defaultContainer, _defaultContainer) &&
Equals(otherObjectQueryCacheKey._eSqlStatement, _eSqlStatement) &&
Equals(otherObjectQueryCacheKey._includePathsToken, _includePathsToken) &&
Equals(otherObjectQueryCacheKey._parametersToken, _parametersToken) &&
Equals(otherObjectQueryCacheKey._resultType, _resultType);
}
///
/// Returns the hashcode for this cache key
///
///
public override int GetHashCode()
{
return _hashCode;
}
///
/// Returns a string representation of the state of this cache key
///
///
/// A string representation that includes query text, parameter information, include path information
/// and merge option information about this cache key.
///
public override string ToString()
{
return String.Join("|", new string[] { _defaultContainer, _eSqlStatement, _parametersToken, _includePathsToken, Enum.GetName(typeof(MergeOption), _mergeOption) });
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- ClientReliableChannelBinder.cs
- JsonQueryStringConverter.cs
- CodeCatchClause.cs
- AdapterDictionary.cs
- ScriptRegistrationManager.cs
- BeginEvent.cs
- MenuScrollingVisibilityConverter.cs
- ConsoleKeyInfo.cs
- ExternalException.cs
- CheckBoxPopupAdapter.cs
- ConfigXmlComment.cs
- PeerInputChannelListener.cs
- OfTypeExpression.cs
- SQLInt32.cs
- XmlNamespaceDeclarationsAttribute.cs
- NamedPipeTransportElement.cs
- Attribute.cs
- SelectedDatesCollection.cs
- ScrollChrome.cs
- LoginNameDesigner.cs
- DBBindings.cs
- shaperfactory.cs
- DataException.cs
- ListControl.cs
- GraphicsPath.cs
- SubqueryRules.cs
- ControlBuilderAttribute.cs
- SiteMapProvider.cs
- XMLSchema.cs
- SiteMapNodeCollection.cs
- AttachmentService.cs
- DataGridViewCellConverter.cs
- ObjectPersistData.cs
- TemplateBindingExpressionConverter.cs
- DispatcherHookEventArgs.cs
- SQLConvert.cs
- _DisconnectOverlappedAsyncResult.cs
- DateTimeOffset.cs
- PasswordRecovery.cs
- RepeatInfo.cs
- RuleElement.cs
- NamedPipeHostedTransportConfiguration.cs
- XmlQualifiedNameTest.cs
- DataServiceQuery.cs
- AssemblyUtil.cs
- TextEditorThreadLocalStore.cs
- AppDomainManager.cs
- ArithmeticException.cs
- XmlSchemaGroup.cs
- XmlReflectionMember.cs
- _SslSessionsCache.cs
- remotingproxy.cs
- DataBindingCollection.cs
- VBCodeProvider.cs
- TextRangeEditTables.cs
- FileChangesMonitor.cs
- AxHost.cs
- SchemaTypeEmitter.cs
- PropertyDescriptorCollection.cs
- DateTimeOffset.cs
- LineProperties.cs
- GlobalProxySelection.cs
- MetadataPropertyCollection.cs
- OdbcConnectionString.cs
- GradientStop.cs
- XmlDataSourceNodeDescriptor.cs
- OperationInvokerTrace.cs
- CodeParameterDeclarationExpressionCollection.cs
- Predicate.cs
- RegexInterpreter.cs
- SerialErrors.cs
- CellIdBoolean.cs
- UiaCoreApi.cs
- EntityContainerEntitySet.cs
- UnauthorizedWebPart.cs
- DateTimeSerializationSection.cs
- CharacterString.cs
- Help.cs
- IconHelper.cs
- EffectiveValueEntry.cs
- DelayDesigner.cs
- CancellationHandler.cs
- WebServiceMethodData.cs
- RegisteredExpandoAttribute.cs
- QueryableFilterRepeater.cs
- NullableDoubleSumAggregationOperator.cs
- XmlSchemaSet.cs
- FixedHighlight.cs
- Model3DGroup.cs
- ImageMapEventArgs.cs
- _LazyAsyncResult.cs
- DataGridViewCellStyleEditor.cs
- DataGridViewLayoutData.cs
- CompilationRelaxations.cs
- DecimalAnimationBase.cs
- Rect3D.cs
- InstallerTypeAttribute.cs
- DataSourceCache.cs
- ParseHttpDate.cs
- EffectiveValueEntry.cs