Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataEntity / System / Data / Map / ViewGeneration / CqlGeneration / JoinCqlBlock.cs / 1305376 / JoinCqlBlock.cs
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common.Utils;
using System.Text;
using System.Collections.Generic;
using System.Data.Mapping.ViewGeneration.Structures;
namespace System.Data.Mapping.ViewGeneration.CqlGeneration
{
// This class corresponds to the various Join nodes in the view, i.e.,
// IJ, LOJ, FOJ
internal class JoinCqlBlock : CqlBlock
{
#region Constructor
// effects: Creates a Join CqlBlock (type given by opType) with
// SELECT (slotinfos), FROM (children), ON (onClauses - one for each child except 0th),
// WHERE (true), AS (blockAliasNum)
internal JoinCqlBlock(CellTreeOpType opType, SlotInfo[] slotInfos, List children,
List onClauses, CqlIdentifiers identifiers, int blockAliasNum) :
base(slotInfos, children, BoolExpression.True, identifiers, blockAliasNum)
{
m_opType = opType;
m_onClauses = onClauses;
}
#endregion
#region Fields
private CellTreeOpType m_opType; // LOJ or IJ etc
private List m_onClauses;
#endregion
#region Methods
// effects: See CqlBlock.AsCql
internal override StringBuilder AsCql(StringBuilder builder, bool isTopLevel, int indentLevel)
{
// The SELECT part
GenerateProjectedtList(builder, indentLevel, CqlAlias, true);
// The FROM part by joining all the children using ON Clauses
builder.Append("FROM ");
int i = 0;
foreach (CqlBlock child in Children)
{
if (i > 0)
{
StringUtil.IndentNewLine(builder, indentLevel + 1);
builder.Append(OpCellTreeNode.OpToCql(m_opType));
}
builder.Append(" (");
child.AsCql(builder, false, indentLevel + 1);
builder.Append(") AS ")
.Append(child.CqlAlias);
// The ON part
if (i > 0)
{
StringUtil.IndentNewLine(builder, indentLevel + 1);
builder.Append("ON ");
m_onClauses[i - 1].AsCql(builder);
}
i++;
}
return builder;
}
#endregion
// A class that represents "slot1 == slot2 AND "slot3 == slot4" ...
// for two join blocks. That is, it is complete ON clause
internal class OnClause : InternalBase
{
#region Constructor
internal OnClause()
{
m_singleClauses = new List();
}
#endregion
#region Fields
private List m_singleClauses;
#endregion
#region Methods
// effects: Modified builder to contain a Cql string of the form "Slot1 = Slot2 AND
// slot3 = slot4 AND ... Returns the builder
internal StringBuilder AsCql(StringBuilder builder)
{
bool isFirst = true;
foreach (SingleClause singleClause in m_singleClauses)
{
if (false == isFirst)
{
builder.Append(" AND ");
}
singleClause.AsCql(builder);
isFirst = false;
}
return builder;
}
// effects: Adds an OnClause element for a join of the form "firstSlot = secondSlot"
internal void Add(AliasedSlot firstSlot, AliasedSlot secondSlot)
{
SingleClause singleClause = new SingleClause(firstSlot, secondSlot);
m_singleClauses.Add(singleClause);
}
internal override void ToCompactString(StringBuilder builder)
{
builder.Append("ON ");
StringUtil.ToSeparatedString(builder, m_singleClauses, " AND ");
}
#endregion
#region Struct
// Denotes an expression between slots of the form: FirstSlot == SecondSlot
private class SingleClause : InternalBase
{
internal SingleClause(AliasedSlot firstSlot, AliasedSlot secondSlot)
{
m_firstSlot = firstSlot;
m_secondSlot = secondSlot;
}
#region Fields
private AliasedSlot m_firstSlot;
private AliasedSlot m_secondSlot;
#endregion
#region Methods
// effects: Modifies builder to constain the Cql string of the form "firstSlot = secondSlot"
// Returns the modified builder
internal StringBuilder AsCql(StringBuilder builder)
{
builder.Append(m_firstSlot.FullCqlAlias())
.Append(" = ")
.Append(m_secondSlot.FullCqlAlias());
return builder;
}
internal override void ToCompactString(StringBuilder builder)
{
m_firstSlot.ToCompactString(builder);
builder.Append(" = ");
m_secondSlot.ToCompactString(builder);
}
#endregion
}
#endregion
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//----------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// @owner [....]
// @backupOwner [....]
//---------------------------------------------------------------------
using System.Data.Common.Utils;
using System.Text;
using System.Collections.Generic;
using System.Data.Mapping.ViewGeneration.Structures;
namespace System.Data.Mapping.ViewGeneration.CqlGeneration
{
// This class corresponds to the various Join nodes in the view, i.e.,
// IJ, LOJ, FOJ
internal class JoinCqlBlock : CqlBlock
{
#region Constructor
// effects: Creates a Join CqlBlock (type given by opType) with
// SELECT (slotinfos), FROM (children), ON (onClauses - one for each child except 0th),
// WHERE (true), AS (blockAliasNum)
internal JoinCqlBlock(CellTreeOpType opType, SlotInfo[] slotInfos, List children,
List onClauses, CqlIdentifiers identifiers, int blockAliasNum) :
base(slotInfos, children, BoolExpression.True, identifiers, blockAliasNum)
{
m_opType = opType;
m_onClauses = onClauses;
}
#endregion
#region Fields
private CellTreeOpType m_opType; // LOJ or IJ etc
private List m_onClauses;
#endregion
#region Methods
// effects: See CqlBlock.AsCql
internal override StringBuilder AsCql(StringBuilder builder, bool isTopLevel, int indentLevel)
{
// The SELECT part
GenerateProjectedtList(builder, indentLevel, CqlAlias, true);
// The FROM part by joining all the children using ON Clauses
builder.Append("FROM ");
int i = 0;
foreach (CqlBlock child in Children)
{
if (i > 0)
{
StringUtil.IndentNewLine(builder, indentLevel + 1);
builder.Append(OpCellTreeNode.OpToCql(m_opType));
}
builder.Append(" (");
child.AsCql(builder, false, indentLevel + 1);
builder.Append(") AS ")
.Append(child.CqlAlias);
// The ON part
if (i > 0)
{
StringUtil.IndentNewLine(builder, indentLevel + 1);
builder.Append("ON ");
m_onClauses[i - 1].AsCql(builder);
}
i++;
}
return builder;
}
#endregion
// A class that represents "slot1 == slot2 AND "slot3 == slot4" ...
// for two join blocks. That is, it is complete ON clause
internal class OnClause : InternalBase
{
#region Constructor
internal OnClause()
{
m_singleClauses = new List();
}
#endregion
#region Fields
private List m_singleClauses;
#endregion
#region Methods
// effects: Modified builder to contain a Cql string of the form "Slot1 = Slot2 AND
// slot3 = slot4 AND ... Returns the builder
internal StringBuilder AsCql(StringBuilder builder)
{
bool isFirst = true;
foreach (SingleClause singleClause in m_singleClauses)
{
if (false == isFirst)
{
builder.Append(" AND ");
}
singleClause.AsCql(builder);
isFirst = false;
}
return builder;
}
// effects: Adds an OnClause element for a join of the form "firstSlot = secondSlot"
internal void Add(AliasedSlot firstSlot, AliasedSlot secondSlot)
{
SingleClause singleClause = new SingleClause(firstSlot, secondSlot);
m_singleClauses.Add(singleClause);
}
internal override void ToCompactString(StringBuilder builder)
{
builder.Append("ON ");
StringUtil.ToSeparatedString(builder, m_singleClauses, " AND ");
}
#endregion
#region Struct
// Denotes an expression between slots of the form: FirstSlot == SecondSlot
private class SingleClause : InternalBase
{
internal SingleClause(AliasedSlot firstSlot, AliasedSlot secondSlot)
{
m_firstSlot = firstSlot;
m_secondSlot = secondSlot;
}
#region Fields
private AliasedSlot m_firstSlot;
private AliasedSlot m_secondSlot;
#endregion
#region Methods
// effects: Modifies builder to constain the Cql string of the form "firstSlot = secondSlot"
// Returns the modified builder
internal StringBuilder AsCql(StringBuilder builder)
{
builder.Append(m_firstSlot.FullCqlAlias())
.Append(" = ")
.Append(m_secondSlot.FullCqlAlias());
return builder;
}
internal override void ToCompactString(StringBuilder builder)
{
m_firstSlot.ToCompactString(builder);
builder.Append(" = ");
m_secondSlot.ToCompactString(builder);
}
#endregion
}
#endregion
}
}
}
// 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
- ExpressionParser.cs
- StyleCollection.cs
- WebPartConnectionsCloseVerb.cs
- HashHelper.cs
- SyntaxCheck.cs
- KoreanCalendar.cs
- AnonymousIdentificationModule.cs
- AttachedPropertyMethodSelector.cs
- PasswordDeriveBytes.cs
- ClientUrlResolverWrapper.cs
- StringFreezingAttribute.cs
- Policy.cs
- KeyNotFoundException.cs
- FixUp.cs
- ApplicationServiceHelper.cs
- IsolatedStorageFileStream.cs
- DataGridViewToolTip.cs
- SqlLiftWhereClauses.cs
- ArraySortHelper.cs
- BCLDebug.cs
- MonitoringDescriptionAttribute.cs
- AuthenticatingEventArgs.cs
- VideoDrawing.cs
- ConfigurationManagerHelperFactory.cs
- SettingsBase.cs
- HitTestWithGeometryDrawingContextWalker.cs
- SoapFault.cs
- DeviceSpecificDialogCachedState.cs
- CanonicalFontFamilyReference.cs
- WebPartVerbCollection.cs
- SafeHandles.cs
- BrushValueSerializer.cs
- CodeAttachEventStatement.cs
- DesignerView.Commands.cs
- ResolveNameEventArgs.cs
- SqlDependencyUtils.cs
- SqlUtils.cs
- SimpleHandlerBuildProvider.cs
- SignatureToken.cs
- TdsValueSetter.cs
- ObjectDataSourceWizardForm.cs
- DataSourceXmlElementAttribute.cs
- CssStyleCollection.cs
- XamlParser.cs
- SqlXmlStorage.cs
- XmlILModule.cs
- WaitForChangedResult.cs
- MasterPageBuildProvider.cs
- CounterCreationData.cs
- TreeViewItem.cs
- PresentationAppDomainManager.cs
- IssuanceLicense.cs
- Accessible.cs
- X500Name.cs
- SqlParameterizer.cs
- ExpressionEditorAttribute.cs
- BinHexEncoder.cs
- _NegoStream.cs
- SchemaDeclBase.cs
- DataGridViewCheckBoxColumn.cs
- Type.cs
- ObjectViewEntityCollectionData.cs
- ReadOnlyHierarchicalDataSource.cs
- TreeViewImageIndexConverter.cs
- DescendentsWalker.cs
- ThrowOnMultipleAssignment.cs
- NodeInfo.cs
- MarkupCompiler.cs
- ContextStaticAttribute.cs
- DataIdProcessor.cs
- CachingParameterInspector.cs
- AppDomainFactory.cs
- TextRenderer.cs
- ToolBarButton.cs
- PageHandlerFactory.cs
- CapabilitiesRule.cs
- Group.cs
- BamlReader.cs
- RepeaterItemEventArgs.cs
- Camera.cs
- CommonObjectSecurity.cs
- ConfigurationSectionCollection.cs
- ScriptReference.cs
- ExtendedPropertyCollection.cs
- StateChangeEvent.cs
- VirtualizingPanel.cs
- DescendentsWalkerBase.cs
- RectIndependentAnimationStorage.cs
- WindowsIPAddress.cs
- OracleConnectionString.cs
- XmlSortKey.cs
- ElementHost.cs
- UnhandledExceptionEventArgs.cs
- X509ChainElement.cs
- NamespaceMapping.cs
- ScaleTransform.cs
- NativeMethods.cs
- AttachedPropertyBrowsableAttribute.cs
- SystemEvents.cs
- AnnotationResourceChangedEventArgs.cs