//---------------------------------------------------------------------
//
// Portions of this file copyright (c) Microsoft Corporation
// and are released under the Microsoft Pulic License. See
// http://archive.msdn.microsoft.com/EFSampleProvider/Project/License.aspx
// or License.txt for details.
// All rights reserved.
//
//---------------------------------------------------------------------
#if USE_ENTITY_FRAMEWORK_6
namespace System.Data.SQLite.EF6
#else
namespace System.Data.SQLite.Linq
#endif
{
using System;
using System.Collections.Generic;
#if USE_ENTITY_FRAMEWORK_6
using System.Data.Entity.Core.Metadata.Edm;
using System.Data.Entity.Core.Common.CommandTrees;
#else
using System.Data.Metadata.Edm;
using System.Data.Common.CommandTrees;
#endif
///
/// A Join symbol is a special kind of Symbol.
/// It has to carry additional information
///
/// - ColumnList for the list of columns in the select clause if this
/// symbol represents a sql select statement. This is set by .
/// - ExtentList is the list of extents in the select clause.
/// - FlattenedExtentList - if the Join has multiple extents flattened at the
/// top level, we need this information to ensure that extent aliases are renamed
/// correctly in
/// - NameToExtent has all the extents in ExtentList as a dictionary.
/// This is used by to flatten
/// record accesses.
/// - IsNestedJoin - is used to determine whether a JoinSymbol is an
/// ordinary join symbol, or one that has a corresponding SqlSelectStatement.
///
///
/// All the lists are set exactly once, and then used for lookups/enumerated.
///
internal sealed class JoinSymbol : Symbol
{
private List columnList;
internal List ColumnList
{
get
{
if (null == columnList)
{
columnList = new List();
}
return columnList;
}
set { columnList = value; }
}
private List extentList;
internal List ExtentList
{
get { return extentList; }
}
private List flattenedExtentList;
internal List FlattenedExtentList
{
get
{
if (null == flattenedExtentList)
{
flattenedExtentList = new List();
}
return flattenedExtentList;
}
set { flattenedExtentList = value; }
}
private Dictionary nameToExtent;
internal Dictionary NameToExtent
{
get { return nameToExtent; }
}
private bool isNestedJoin;
internal bool IsNestedJoin
{
get { return isNestedJoin; }
set { isNestedJoin = value; }
}
public JoinSymbol(string name, TypeUsage type, List extents)
: base(name, type)
{
extentList = new List(extents.Count);
nameToExtent = new Dictionary(extents.Count, StringComparer.OrdinalIgnoreCase);
foreach (Symbol symbol in extents)
{
this.nameToExtent[symbol.Name] = symbol;
this.ExtentList.Add(symbol);
}
}
}
}