You've already forked linux-packaging-mono
Imported Upstream version 4.6.0.125
Former-commit-id: a2155e9bd80020e49e72e86c44da02a8ac0e57a4
This commit is contained in:
parent
a569aebcfd
commit
e79aa3c0ed
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,94 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="Aggregates.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Aggregates are pseudo-expressions. They look and feel like expressions, but
|
||||
/// are severely restricted in where they can appear - only in the aggregates clause
|
||||
/// of a group-by expression.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public abstract class DbAggregate
|
||||
{
|
||||
private readonly DbExpressionList _args;
|
||||
private readonly TypeUsage _type;
|
||||
|
||||
internal DbAggregate(TypeUsage resultType, DbExpressionList arguments)
|
||||
{
|
||||
Debug.Assert(resultType != null, "DbAggregate.ResultType cannot be null");
|
||||
Debug.Assert(arguments != null, "DbAggregate.Arguments cannot be null");
|
||||
Debug.Assert(arguments.Count == 1, "DbAggregate requires a single argument");
|
||||
|
||||
this._type = resultType;
|
||||
this._args = arguments;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the result type of this aggregate
|
||||
/// </summary>
|
||||
public TypeUsage ResultType
|
||||
{
|
||||
get { return _type; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of expressions that define the arguments to the aggregate.
|
||||
/// </summary>
|
||||
public IList<DbExpression> Arguments { get { return _args; } }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The aggregate type that corresponds to exposing the collection of elements that comprise a group
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbGroupAggregate : DbAggregate
|
||||
{
|
||||
internal DbGroupAggregate(TypeUsage resultType, DbExpressionList arguments)
|
||||
: base(resultType, arguments)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The aggregate type that corresponds to the invocation of an aggregate function.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbFunctionAggregate : DbAggregate
|
||||
{
|
||||
private bool _distinct;
|
||||
EdmFunction _aggregateFunction;
|
||||
|
||||
internal DbFunctionAggregate(TypeUsage resultType, DbExpressionList arguments, EdmFunction function, bool isDistinct)
|
||||
: base(resultType, arguments)
|
||||
{
|
||||
Debug.Assert(function != null, "DbFunctionAggregate.Function cannot be null");
|
||||
|
||||
_aggregateFunction = function;
|
||||
_distinct = isDistinct;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the aggregate function is applied in a distinct fashion
|
||||
/// </summary>
|
||||
public bool Distinct { get { return _distinct; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the method metadata that specifies the aggregate function to invoke.
|
||||
/// </summary>
|
||||
public EdmFunction Function { get { return _aggregateFunction; } }
|
||||
}
|
||||
}
|
@@ -0,0 +1,133 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="BasicCommandTreeVisitor.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// An abstract base type for types that implement the IExpressionVisitor interface to derive from.
|
||||
/// </summary>
|
||||
/*CQT_PUBLIC_API(*/internal/*)*/ abstract class BasicCommandTreeVisitor : BasicExpressionVisitor
|
||||
{
|
||||
#region protected API, may be overridden to add functionality at specific points in the traversal
|
||||
|
||||
protected virtual void VisitSetClause(DbSetClause setClause)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(setClause, "setClause");
|
||||
this.VisitExpression(setClause.Property);
|
||||
this.VisitExpression(setClause.Value);
|
||||
}
|
||||
|
||||
protected virtual void VisitModificationClause(DbModificationClause modificationClause)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(modificationClause, "modificationClause");
|
||||
// Set clause is the only current possibility
|
||||
this.VisitSetClause((DbSetClause)modificationClause);
|
||||
}
|
||||
|
||||
protected virtual void VisitModificationClauses(IList<DbModificationClause> modificationClauses)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(modificationClauses, "modificationClauses");
|
||||
for (int idx = 0; idx < modificationClauses.Count; idx++)
|
||||
{
|
||||
this.VisitModificationClause(modificationClauses[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region public convenience API
|
||||
|
||||
public virtual void VisitCommandTree(DbCommandTree commandTree)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(commandTree, "commandTree");
|
||||
switch (commandTree.CommandTreeKind)
|
||||
{
|
||||
case DbCommandTreeKind.Delete:
|
||||
this.VisitDeleteCommandTree((DbDeleteCommandTree)commandTree);
|
||||
break;
|
||||
|
||||
case DbCommandTreeKind.Function:
|
||||
this.VisitFunctionCommandTree((DbFunctionCommandTree)commandTree);
|
||||
break;
|
||||
|
||||
case DbCommandTreeKind.Insert:
|
||||
this.VisitInsertCommandTree((DbInsertCommandTree)commandTree);
|
||||
break;
|
||||
|
||||
case DbCommandTreeKind.Query:
|
||||
this.VisitQueryCommandTree((DbQueryCommandTree)commandTree);
|
||||
break;
|
||||
|
||||
case DbCommandTreeKind.Update:
|
||||
this.VisitUpdateCommandTree((DbUpdateCommandTree)commandTree);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw EntityUtil.NotSupported();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region CommandTree-specific Visitor Methods
|
||||
|
||||
protected virtual void VisitDeleteCommandTree(DbDeleteCommandTree deleteTree)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(deleteTree, "deleteTree");
|
||||
this.VisitExpressionBindingPre(deleteTree.Target);
|
||||
this.VisitExpression(deleteTree.Predicate);
|
||||
this.VisitExpressionBindingPost(deleteTree.Target);
|
||||
}
|
||||
|
||||
protected virtual void VisitFunctionCommandTree(DbFunctionCommandTree functionTree)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(functionTree, "functionTree");
|
||||
|
||||
}
|
||||
|
||||
protected virtual void VisitInsertCommandTree(DbInsertCommandTree insertTree)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(insertTree, "insertTree");
|
||||
this.VisitExpressionBindingPre(insertTree.Target);
|
||||
this.VisitModificationClauses(insertTree.SetClauses);
|
||||
if (insertTree.Returning != null)
|
||||
{
|
||||
this.VisitExpression(insertTree.Returning);
|
||||
}
|
||||
this.VisitExpressionBindingPost(insertTree.Target);
|
||||
}
|
||||
|
||||
protected virtual void VisitQueryCommandTree(DbQueryCommandTree queryTree)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(queryTree, "queryTree");
|
||||
this.VisitExpression(queryTree.Query);
|
||||
}
|
||||
|
||||
protected virtual void VisitUpdateCommandTree(DbUpdateCommandTree updateTree)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(updateTree, "updateTree");
|
||||
this.VisitExpressionBindingPre(updateTree.Target);
|
||||
this.VisitModificationClauses(updateTree.SetClauses);
|
||||
this.VisitExpression(updateTree.Predicate);
|
||||
if (updateTree.Returning != null)
|
||||
{
|
||||
this.VisitExpression(updateTree.Returning);
|
||||
}
|
||||
this.VisitExpressionBindingPost(updateTree.Target);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,206 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbCommandTree.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
/// <summary>
|
||||
/// Describes the different "kinds" (classes) of command trees.
|
||||
/// </summary>
|
||||
internal enum DbCommandTreeKind
|
||||
{
|
||||
Query,
|
||||
Update,
|
||||
Insert,
|
||||
Delete,
|
||||
Function,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DbCommandTree is the abstract base type for the Delete, Query, Insert and Update DbCommandTree types.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public abstract class DbCommandTree
|
||||
{
|
||||
// Metadata collection
|
||||
private readonly MetadataWorkspace _metadata;
|
||||
private readonly DataSpace _dataSpace;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new command tree with a given metadata workspace.
|
||||
/// </summary>
|
||||
/// <param name="metadata">The metadata workspace against which the command tree should operate.</param>
|
||||
/// <param name="dataSpace">The logical 'space' that metadata in the expressions used in this command tree must belong to.</param>
|
||||
internal DbCommandTree(MetadataWorkspace metadata, DataSpace dataSpace)
|
||||
{
|
||||
// Ensure the metadata workspace is non-null
|
||||
EntityUtil.CheckArgumentNull(metadata, "metadata");
|
||||
|
||||
// Ensure that the data space value is valid
|
||||
if (!DbCommandTree.IsValidDataSpace(dataSpace))
|
||||
{
|
||||
throw EntityUtil.Argument(System.Data.Entity.Strings.Cqt_CommandTree_InvalidDataSpace, "dataSpace");
|
||||
}
|
||||
|
||||
//
|
||||
// Create the tree's metadata workspace and initalize commonly used types.
|
||||
//
|
||||
MetadataWorkspace effectiveMetadata = new MetadataWorkspace();
|
||||
|
||||
//While EdmItemCollection and StorageitemCollections are required
|
||||
//ObjectItemCollection may or may not be registered on the workspace yet.
|
||||
//So register the ObjectItemCollection if it exists.
|
||||
ItemCollection objectItemCollection;
|
||||
if (metadata.TryGetItemCollection(DataSpace.OSpace, out objectItemCollection))
|
||||
{
|
||||
effectiveMetadata.RegisterItemCollection(objectItemCollection);
|
||||
}
|
||||
effectiveMetadata.RegisterItemCollection(metadata.GetItemCollection(DataSpace.CSpace));
|
||||
effectiveMetadata.RegisterItemCollection(metadata.GetItemCollection(DataSpace.CSSpace));
|
||||
effectiveMetadata.RegisterItemCollection(metadata.GetItemCollection(DataSpace.SSpace));
|
||||
|
||||
this._metadata = effectiveMetadata;
|
||||
this._dataSpace = dataSpace;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name and corresponding type of each parameter that can be referenced within this command tree.
|
||||
/// </summary>
|
||||
public IEnumerable<KeyValuePair<string, TypeUsage>> Parameters
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.GetParameters();
|
||||
}
|
||||
}
|
||||
|
||||
#region Internal Implementation
|
||||
|
||||
/// <summary>
|
||||
/// Gets the kind of this command tree.
|
||||
/// </summary>
|
||||
internal abstract DbCommandTreeKind CommandTreeKind { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name and type of each parameter declared on the command tree.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal abstract IEnumerable<KeyValuePair<string, TypeUsage>> GetParameters();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the metadata workspace used by this command tree.
|
||||
/// </summary>
|
||||
internal MetadataWorkspace MetadataWorkspace { get { return _metadata; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the data space in which metadata used by this command tree must reside.
|
||||
/// </summary>
|
||||
internal DataSpace DataSpace { get { return _dataSpace; } }
|
||||
|
||||
#region Dump/Print Support
|
||||
|
||||
internal void Dump(ExpressionDumper dumper)
|
||||
{
|
||||
//
|
||||
// Dump information about this command tree to the specified ExpressionDumper
|
||||
//
|
||||
// First dump standard information - the DataSpace of the command tree and its parameters
|
||||
//
|
||||
Dictionary<string, object> attrs = new Dictionary<string, object>();
|
||||
attrs.Add("DataSpace", this.DataSpace);
|
||||
dumper.Begin(this.GetType().Name, attrs);
|
||||
|
||||
//
|
||||
// The name and type of each Parameter in turn is added to the output
|
||||
//
|
||||
dumper.Begin("Parameters", null);
|
||||
foreach (KeyValuePair<string, TypeUsage> param in this.Parameters)
|
||||
{
|
||||
Dictionary<string, object> paramAttrs = new Dictionary<string, object>();
|
||||
paramAttrs.Add("Name", param.Key);
|
||||
dumper.Begin("Parameter", paramAttrs);
|
||||
dumper.Dump(param.Value, "ParameterType");
|
||||
dumper.End("Parameter");
|
||||
}
|
||||
dumper.End("Parameters");
|
||||
|
||||
//
|
||||
// Delegate to the derived type's implementation that dumps the structure of the command tree
|
||||
//
|
||||
this.DumpStructure(dumper);
|
||||
|
||||
//
|
||||
// Matching call to End to correspond with the call to Begin above
|
||||
//
|
||||
dumper.End(this.GetType().Name);
|
||||
}
|
||||
|
||||
internal abstract void DumpStructure(ExpressionDumper dumper);
|
||||
|
||||
internal string DumpXml()
|
||||
{
|
||||
//
|
||||
// This is a convenience method that dumps the command tree in an XML format.
|
||||
// This is intended primarily as a debugging aid to allow inspection of the tree structure.
|
||||
//
|
||||
// Create a new MemoryStream that the XML dumper should write to.
|
||||
//
|
||||
MemoryStream stream = new MemoryStream();
|
||||
|
||||
//
|
||||
// Create the dumper
|
||||
//
|
||||
XmlExpressionDumper dumper = new XmlExpressionDumper(stream);
|
||||
|
||||
//
|
||||
// Dump this tree and then close the XML dumper so that the end document tag is written
|
||||
// and the output is flushed to the stream.
|
||||
//
|
||||
this.Dump(dumper);
|
||||
dumper.Close();
|
||||
|
||||
//
|
||||
// Construct a string from the resulting memory stream and return it to the caller
|
||||
//
|
||||
return XmlExpressionDumper.DefaultEncoding.GetString(stream.ToArray());
|
||||
}
|
||||
|
||||
internal string Print()
|
||||
{
|
||||
return this.PrintTree(new ExpressionPrinter());
|
||||
}
|
||||
|
||||
internal abstract string PrintTree(ExpressionPrinter printer);
|
||||
|
||||
#endregion
|
||||
|
||||
internal static bool IsValidDataSpace(DataSpace dataSpace)
|
||||
{
|
||||
return (DataSpace.OSpace == dataSpace ||
|
||||
DataSpace.CSpace == dataSpace ||
|
||||
DataSpace.SSpace == dataSpace);
|
||||
}
|
||||
|
||||
internal static bool IsValidParameterName(string name)
|
||||
{
|
||||
return (!StringUtil.IsNullOrEmptyOrWhiteSpace(name) &&
|
||||
_paramNameRegex.IsMatch(name));
|
||||
}
|
||||
private static readonly Regex _paramNameRegex = new Regex("^([A-Za-z])([A-Za-z0-9_])*$");
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,89 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbDeleteCommandTree.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....], [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.Utils;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a single row delete operation expressed as a canonical command tree.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbDeleteCommandTree : DbModificationCommandTree
|
||||
{
|
||||
private readonly DbExpression _predicate;
|
||||
|
||||
internal DbDeleteCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpressionBinding target, DbExpression predicate)
|
||||
: base(metadata, dataSpace, target)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(predicate, "predicate");
|
||||
|
||||
this._predicate = predicate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="DbExpression"/> that specifies the predicate used to determine which members of the target collection should be deleted.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The predicate can include only the following elements:
|
||||
/// <list>
|
||||
/// <item>Equality expression</item>
|
||||
/// <item>Constant expression</item>
|
||||
/// <item>IsNull expression</item>
|
||||
/// <item>Property expression</item>
|
||||
/// <item>Reference expression to the target</item>
|
||||
/// <item>And expression</item>
|
||||
/// <item>Or expression</item>
|
||||
/// <item>Not expression</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public DbExpression Predicate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _predicate;
|
||||
}
|
||||
}
|
||||
|
||||
internal override DbCommandTreeKind CommandTreeKind
|
||||
{
|
||||
get { return DbCommandTreeKind.Delete; }
|
||||
}
|
||||
|
||||
internal override bool HasReader
|
||||
{
|
||||
get
|
||||
{
|
||||
// a delete command never returns server-gen values, and
|
||||
// therefore never returns a reader
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void DumpStructure(ExpressionDumper dumper)
|
||||
{
|
||||
base.DumpStructure(dumper);
|
||||
|
||||
if (this.Predicate != null)
|
||||
{
|
||||
dumper.Dump(this.Predicate, "Predicate");
|
||||
}
|
||||
}
|
||||
|
||||
internal override string PrintTree(ExpressionPrinter printer)
|
||||
{
|
||||
return printer.Print(this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,290 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbExpressionVisitor.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Metadata.Edm;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// The expression visitor pattern abstract base class that should be implemented by visitors that do not return a result value.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public abstract class DbExpressionVisitor
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when an expression of an otherwise unrecognized type is encountered.
|
||||
/// </summary>
|
||||
/// <param name="expression">The expression</param>
|
||||
public abstract void Visit(DbExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbAndExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbAndExpression that is being visited.</param>
|
||||
public abstract void Visit(DbAndExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbApplyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbApplyExpression that is being visited.</param>
|
||||
public abstract void Visit(DbApplyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbArithmeticExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbArithmeticExpression that is being visited.</param>
|
||||
public abstract void Visit(DbArithmeticExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbCaseExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbCaseExpression that is being visited.</param>
|
||||
public abstract void Visit(DbCaseExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbCastExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbCastExpression that is being visited.</param>
|
||||
public abstract void Visit(DbCastExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbComparisonExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbComparisonExpression that is being visited.</param>
|
||||
public abstract void Visit(DbComparisonExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbConstantExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbConstantExpression that is being visited.</param>
|
||||
public abstract void Visit(DbConstantExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbCrossJoinExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbCrossJoinExpression that is being visited.</param>
|
||||
public abstract void Visit(DbCrossJoinExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbDerefExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbDerefExpression that is being visited.</param>
|
||||
public abstract void Visit(DbDerefExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbDistinctExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbDistinctExpression that is being visited.</param>
|
||||
public abstract void Visit(DbDistinctExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbElementExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbElementExpression that is being visited.</param>
|
||||
public abstract void Visit(DbElementExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbExceptExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbExceptExpression that is being visited.</param>
|
||||
public abstract void Visit(DbExceptExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbFilterExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbFilterExpression that is being visited.</param>
|
||||
public abstract void Visit(DbFilterExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbFunctionExpression
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbFunctionExpression that is being visited.</param>
|
||||
public abstract void Visit(DbFunctionExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbEntityRefExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbEntityRefExpression that is being visited.</param>
|
||||
public abstract void Visit(DbEntityRefExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbRefKeyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbRefKeyExpression that is being visited.</param>
|
||||
public abstract void Visit(DbRefKeyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbGroupByExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbGroupByExpression that is being visited.</param>
|
||||
public abstract void Visit(DbGroupByExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbIntersectExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIntersectExpression that is being visited.</param>
|
||||
public abstract void Visit(DbIntersectExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbIsEmptyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIsEmptyExpression that is being visited.</param>
|
||||
public abstract void Visit(DbIsEmptyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbIsNullExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIsNullExpression that is being visited.</param>
|
||||
public abstract void Visit(DbIsNullExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbIsOfExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIsOfExpression that is being visited.</param>
|
||||
public abstract void Visit(DbIsOfExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbJoinExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbJoinExpression that is being visited.</param>
|
||||
public abstract void Visit(DbJoinExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbLambdaExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbLambdaExpression that is being visited.</param>
|
||||
public virtual void Visit(DbLambdaExpression expression)
|
||||
{
|
||||
throw EntityUtil.NotSupported();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbLikeExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbLikeExpression that is being visited.</param>
|
||||
public abstract void Visit(DbLikeExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbLimitExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbLimitExpression that is being visited.</param>
|
||||
public abstract void Visit(DbLimitExpression expression);
|
||||
|
||||
#if METHOD_EXPRESSION
|
||||
/// <summary>
|
||||
/// Visitor pattern method for MethodExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The MethodExpression that is being visited.</param>
|
||||
public abstract void Visit(MethodExpression expression);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbNewInstanceExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbNewInstanceExpression that is being visited.</param>
|
||||
public abstract void Visit(DbNewInstanceExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbNotExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbNotExpression that is being visited.</param>
|
||||
public abstract void Visit(DbNotExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbNullExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbNullExpression that is being visited.</param>
|
||||
public abstract void Visit(DbNullExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbOfTypeExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbOfTypeExpression that is being visited.</param>
|
||||
public abstract void Visit(DbOfTypeExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbOrExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbOrExpression that is being visited.</param>
|
||||
public abstract void Visit(DbOrExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbParameterReferenceExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbParameterReferenceExpression that is being visited.</param>
|
||||
public abstract void Visit(DbParameterReferenceExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbProjectExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbProjectExpression that is being visited.</param>
|
||||
public abstract void Visit(DbProjectExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbPropertyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbPropertyExpression that is being visited.</param>
|
||||
public abstract void Visit(DbPropertyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbQuantifierExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbQuantifierExpression that is being visited.</param>
|
||||
public abstract void Visit(DbQuantifierExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbRefExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbRefExpression that is being visited.</param>
|
||||
public abstract void Visit(DbRefExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbRelationshipNavigationExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbRelationshipNavigationExpression that is being visited.</param>
|
||||
public abstract void Visit(DbRelationshipNavigationExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbScanExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbScanExpression that is being visited.</param>
|
||||
public abstract void Visit(DbScanExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbSkipExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbSkipExpression that is being visited.</param>
|
||||
public abstract void Visit(DbSkipExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbSortExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbSortExpression that is being visited.</param>
|
||||
public abstract void Visit(DbSortExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbTreatExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbTreatExpression that is being visited.</param>
|
||||
public abstract void Visit(DbTreatExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbUnionAllExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbUnionAllExpression that is being visited.</param>
|
||||
public abstract void Visit(DbUnionAllExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbVariableReferenceExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbVariableReferenceExpression that is being visited.</param>
|
||||
public abstract void Visit(DbVariableReferenceExpression expression);
|
||||
}
|
||||
}
|
@@ -0,0 +1,334 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbExpressionVisitor_TResultType.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Metadata.Edm;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// The expression visitor pattern abstract base class that should be implemented by visitors that return a result value of a specific type.
|
||||
/// </summary>
|
||||
/// <typeparam name="TResultType">The type of the result value produced by the visitor.</typeparam>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public abstract class DbExpressionVisitor<TResultType>
|
||||
{
|
||||
/// <summary>
|
||||
/// Called when an expression of an otherwise unrecognized type is encountered.
|
||||
/// </summary>
|
||||
/// <param name="expression">The expression.</param>
|
||||
public abstract TResultType Visit(DbExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbAndExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbAndExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbAndExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbApplyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbApplyExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbApplyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbArithmeticExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbArithmeticExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbArithmeticExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbCaseExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbCaseExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbCaseExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbCastExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbCastExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbCastExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbComparisonExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbComparisonExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbComparisonExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbConstantExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbConstantExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbConstantExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbCrossJoinExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbCrossJoinExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbCrossJoinExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbDerefExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbDerefExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbDerefExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbDistinctExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbDistinctExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbDistinctExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbElementExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbElementExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbElementExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbExceptExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbExceptExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbExceptExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbFilterExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbFilterExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbFilterExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbFunctionExpression
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbFunctionExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbFunctionExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbEntityRefExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbEntityRefExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbEntityRefExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbRefKeyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbRefKeyExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbRefKeyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbGroupByExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbGroupByExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbGroupByExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbIntersectExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIntersectExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbIntersectExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbIsEmptyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIsEmptyExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbIsEmptyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbIsNullExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIsNullExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbIsNullExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbIsOfExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbIsOfExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbIsOfExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbJoinExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbJoinExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbJoinExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbLambdaExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbLambdaExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public virtual TResultType Visit(DbLambdaExpression expression)
|
||||
{
|
||||
throw EntityUtil.NotSupported();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbLikeExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbLikeExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbLikeExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Visitor pattern method for DbLimitExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbLimitExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbLimitExpression expression);
|
||||
|
||||
#if METHOD_EXPRESSION
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for MethodExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The Expression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(MethodExpression expression);
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbNewInstanceExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbNewInstanceExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbNewInstanceExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbNotExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbNotExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbNotExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbNullExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbNullExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbNullExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbOfTypeExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbOfTypeExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbOfTypeExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbOrExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbOrExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbOrExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbParameterReferenceExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbParameterReferenceExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbParameterReferenceExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbProjectExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbProjectExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbProjectExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbPropertyExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbPropertyExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbPropertyExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbQuantifierExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbQuantifierExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbQuantifierExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbRefExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbRefExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbRefExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbRelationshipNavigationExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbRelationshipNavigationExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbRelationshipNavigationExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbScanExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbScanExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbScanExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbSortExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbSortExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbSortExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbSkipExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbSkipExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbSkipExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbTreatExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbTreatExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbTreatExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbUnionAllExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbUnionAllExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbUnionAllExpression expression);
|
||||
|
||||
/// <summary>
|
||||
/// Typed visitor pattern method for DbVariableReferenceExpression.
|
||||
/// </summary>
|
||||
/// <param name="expression">The DbVariableReferenceExpression that is being visited.</param>
|
||||
/// <returns>An instance of TResultType.</returns>
|
||||
public abstract TResultType Visit(DbVariableReferenceExpression expression);
|
||||
}
|
||||
}
|
@@ -0,0 +1,116 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbFunctionCommandTree.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Linq;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Represents a function invocation expressed as a canonical command tree
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbFunctionCommandTree : DbCommandTree
|
||||
{
|
||||
private readonly EdmFunction _edmFunction;
|
||||
private readonly TypeUsage _resultType;
|
||||
private readonly System.Collections.ObjectModel.ReadOnlyCollection<string> _parameterNames;
|
||||
private readonly System.Collections.ObjectModel.ReadOnlyCollection<TypeUsage> _parameterTypes;
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new DbFunctionCommandTree that uses the specified metadata workspace, data space and function metadata
|
||||
/// </summary>
|
||||
/// <param name="metadata">The metadata workspace that the command tree should use.</param>
|
||||
/// <param name="dataSpace">The logical 'space' that metadata in the expressions used in this command tree must belong to.</param>
|
||||
/// <param name="edmFunction"></param>
|
||||
/// <param name="resultType"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="metadata"/>, <paramref name="dataSpace"/> or <paramref name="edmFunction"/> is null</exception>
|
||||
/// <exception cref="ArgumentException"><paramref name="dataSpace"/> does not represent a valid data space or
|
||||
/// <paramref name="edmFunction">is a composable function</paramref></exception>
|
||||
/*CQT_PUBLIC_API(*/internal/*)*/ DbFunctionCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, EdmFunction edmFunction, TypeUsage resultType, IEnumerable<KeyValuePair<string, TypeUsage>> parameters)
|
||||
: base(metadata, dataSpace)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(edmFunction, "edmFunction");
|
||||
|
||||
_edmFunction = edmFunction;
|
||||
_resultType = resultType;
|
||||
|
||||
List<string> paramNames = new List<string>();
|
||||
List<TypeUsage> paramTypes = new List<TypeUsage>();
|
||||
if (parameters != null)
|
||||
{
|
||||
foreach (KeyValuePair<string, TypeUsage> paramInfo in parameters)
|
||||
{
|
||||
paramNames.Add(paramInfo.Key);
|
||||
paramTypes.Add(paramInfo.Value);
|
||||
}
|
||||
}
|
||||
|
||||
_parameterNames = paramNames.AsReadOnly();
|
||||
_parameterTypes = paramTypes.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="EdmFunction"/> that represents the function to invoke
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Edm")]
|
||||
public EdmFunction EdmFunction
|
||||
{
|
||||
get
|
||||
{
|
||||
return _edmFunction;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the result type of the function; currently constrained to be a Collection of
|
||||
/// RowTypes. Unlike typical RowType instance, merely indicates name/type not parameter
|
||||
/// order.
|
||||
/// </summary>
|
||||
public TypeUsage ResultType
|
||||
{
|
||||
get
|
||||
{
|
||||
return _resultType;
|
||||
}
|
||||
}
|
||||
|
||||
internal override DbCommandTreeKind CommandTreeKind
|
||||
{
|
||||
get { return DbCommandTreeKind.Function; }
|
||||
}
|
||||
|
||||
internal override IEnumerable<KeyValuePair<string, TypeUsage>> GetParameters()
|
||||
{
|
||||
for (int idx = 0; idx < this._parameterNames.Count; idx++)
|
||||
{
|
||||
yield return new KeyValuePair<string, TypeUsage>(this._parameterNames[idx], this._parameterTypes[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
internal override void DumpStructure(ExpressionDumper dumper)
|
||||
{
|
||||
if (this.EdmFunction != null)
|
||||
{
|
||||
dumper.Dump(this.EdmFunction);
|
||||
}
|
||||
}
|
||||
|
||||
internal override string PrintTree(ExpressionPrinter printer)
|
||||
{
|
||||
return printer.Print(this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,108 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbInsertCommandTree.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....], [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.ObjectModel;
|
||||
using ReadOnlyModificationClauses = System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.CommandTrees.DbModificationClause>; // System.Data.Common.ReadOnlyCollection conflicts
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a single row insert operation expressed as a canonical command tree.
|
||||
/// When the <see cref="Returning"/> property is set, the command returns a reader; otherwise,
|
||||
/// it returns a scalar value indicating the number of rows affected.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbInsertCommandTree : DbModificationCommandTree
|
||||
{
|
||||
private readonly ReadOnlyModificationClauses _setClauses;
|
||||
private readonly DbExpression _returning;
|
||||
|
||||
internal DbInsertCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpressionBinding target, ReadOnlyModificationClauses setClauses, DbExpression returning)
|
||||
: base(metadata, dataSpace, target)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(setClauses, "setClauses");
|
||||
// returning may be null
|
||||
|
||||
this._setClauses = setClauses;
|
||||
this._returning = returning;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets set clauses determining values of columns in the inserted row.
|
||||
/// </summary>
|
||||
public IList<DbModificationClause> SetClauses
|
||||
{
|
||||
get
|
||||
{
|
||||
return _setClauses;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="DbExpression"/> that specifies a projection of results to be returned based on the modified rows.
|
||||
/// If null, indicates no results should be returned from this command.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The returning projection includes only the following elements:
|
||||
/// <list>
|
||||
/// <item>NewInstance expression</item>
|
||||
/// <item>Property expression</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public DbExpression Returning
|
||||
{
|
||||
get
|
||||
{
|
||||
return _returning;
|
||||
}
|
||||
}
|
||||
|
||||
internal override DbCommandTreeKind CommandTreeKind
|
||||
{
|
||||
get { return DbCommandTreeKind.Insert; }
|
||||
}
|
||||
|
||||
internal override bool HasReader
|
||||
{
|
||||
get { return null != Returning; }
|
||||
}
|
||||
|
||||
internal override void DumpStructure(ExpressionDumper dumper)
|
||||
{
|
||||
base.DumpStructure(dumper);
|
||||
|
||||
dumper.Begin("SetClauses");
|
||||
foreach (DbModificationClause clause in this.SetClauses)
|
||||
{
|
||||
if (null != clause)
|
||||
{
|
||||
clause.DumpStructure(dumper);
|
||||
}
|
||||
}
|
||||
dumper.End("SetClauses");
|
||||
|
||||
if (null != this.Returning)
|
||||
{
|
||||
dumper.Dump(this.Returning, "Returning");
|
||||
}
|
||||
}
|
||||
|
||||
internal override string PrintTree(ExpressionPrinter printer)
|
||||
{
|
||||
return printer.Print(this);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbModificationClause.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a single clause in an insert or update modification operation, see
|
||||
/// <see cref="DbInsertCommandTree.SetClauses"/> and <see cref="DbUpdateCommandTree.SetClauses"/>
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// An abstract base class allows the possibility of patterns other than
|
||||
/// Property = Value in future versions, e.g.,
|
||||
/// <code>
|
||||
/// update Foo
|
||||
/// set ComplexTypeColumn.Bar()
|
||||
/// where Id = 2
|
||||
/// </code>
|
||||
/// </remarks>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public abstract class DbModificationClause
|
||||
{
|
||||
internal DbModificationClause()
|
||||
{
|
||||
}
|
||||
|
||||
// Effects: describes the contents of this clause using the given dumper
|
||||
internal abstract void DumpStructure(ExpressionDumper dumper);
|
||||
|
||||
// Effects: produces a tree node describing this clause, recursively producing nodes
|
||||
// for child expressions using the given expression visitor
|
||||
internal abstract TreeNode Print(DbExpressionVisitor<TreeNode> visitor);
|
||||
}
|
||||
}
|
@@ -0,0 +1,73 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbModificationCommandTree.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....], [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Linq;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a DML operation expressed as a canonical command tree
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public abstract class DbModificationCommandTree : DbCommandTree
|
||||
{
|
||||
private readonly DbExpressionBinding _target;
|
||||
private System.Collections.ObjectModel.ReadOnlyCollection<DbParameterReferenceExpression> _parameters;
|
||||
|
||||
internal DbModificationCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpressionBinding target)
|
||||
: base(metadata, dataSpace)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(target, "target");
|
||||
|
||||
this._target = target;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DbExpressionBinding"/> that specifies the target table for the DML operation.
|
||||
/// </summary>
|
||||
public DbExpressionBinding Target
|
||||
{
|
||||
get
|
||||
{
|
||||
return _target;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this modification command returns a reader (for instance, to return server generated values)
|
||||
/// </summary>
|
||||
internal abstract bool HasReader
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
internal override IEnumerable<KeyValuePair<string, TypeUsage>> GetParameters()
|
||||
{
|
||||
if (this._parameters == null)
|
||||
{
|
||||
this._parameters = ParameterRetriever.GetParameters(this);
|
||||
}
|
||||
return this._parameters.Select(p => new KeyValuePair<string, TypeUsage>(p.ParameterName, p.ResultType));
|
||||
}
|
||||
|
||||
internal override void DumpStructure(ExpressionDumper dumper)
|
||||
{
|
||||
if (this.Target != null)
|
||||
{
|
||||
dumper.Dump(this.Target, "Target");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbQueryCommandTree.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Linq;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a query operation expressed as a canonical command tree.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbQueryCommandTree : DbCommandTree
|
||||
{
|
||||
// Query expression
|
||||
private readonly DbExpression _query;
|
||||
|
||||
// Parameter information (will be retrieved from the query expression of the command tree during construction)
|
||||
private System.Collections.ObjectModel.ReadOnlyCollection<DbParameterReferenceExpression> _parameters;
|
||||
|
||||
private DbQueryCommandTree(MetadataWorkspace metadata,
|
||||
DataSpace dataSpace,
|
||||
DbExpression query,
|
||||
bool validate)
|
||||
: base(metadata, dataSpace)
|
||||
{
|
||||
// Ensure the query expression is non-null
|
||||
EntityUtil.CheckArgumentNull(query, "query");
|
||||
|
||||
if (validate)
|
||||
{
|
||||
// Use the valid workspace and data space to validate the query expression
|
||||
DbExpressionValidator validator = new DbExpressionValidator(metadata, dataSpace);
|
||||
validator.ValidateExpression(query, "query");
|
||||
|
||||
this._parameters = validator.Parameters.Select(paramInfo => paramInfo.Value).ToList().AsReadOnly();
|
||||
}
|
||||
this._query = query;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Constructs a new DbQueryCommandTree that uses the specified metadata workspace.
|
||||
/// </summary>
|
||||
/// <param name="metadata">The metadata workspace that the command tree should use.</param>
|
||||
/// <param name="dataSpace">The logical 'space' that metadata in the expressions used in this command tree must belong to.</param>
|
||||
/// <param name="query">A <see cref="DbExpression"/> that defines the logic of the query.</param>
|
||||
/// <exception cref="ArgumentNullException"><paramref name="metadata"/> or <paramref name="query"/> is null</exception>
|
||||
/// <exception cref="ArgumentException"><paramref name="dataSpace"/> does not represent a valid data space</exception>
|
||||
/*CQT_PUBLIC_API(*/internal/*)*/ DbQueryCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpression query)
|
||||
: this(metadata, dataSpace, query, true)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="DbExpression"/> that defines the logic of the query.
|
||||
/// </summary>
|
||||
public DbExpression Query
|
||||
{
|
||||
get { return this._query; }
|
||||
}
|
||||
|
||||
internal override DbCommandTreeKind CommandTreeKind
|
||||
{
|
||||
get { return DbCommandTreeKind.Query; }
|
||||
}
|
||||
|
||||
internal override IEnumerable<KeyValuePair<string, TypeUsage>> GetParameters()
|
||||
{
|
||||
if (this._parameters == null)
|
||||
{
|
||||
this._parameters = ParameterRetriever.GetParameters(this);
|
||||
}
|
||||
return this._parameters.Select(p => new KeyValuePair<string, TypeUsage>(p.ParameterName, p.ResultType));
|
||||
}
|
||||
|
||||
internal override void DumpStructure(ExpressionDumper dumper)
|
||||
{
|
||||
if (this.Query != null)
|
||||
{
|
||||
dumper.Dump(this.Query, "Query");
|
||||
}
|
||||
}
|
||||
|
||||
internal override string PrintTree(ExpressionPrinter printer)
|
||||
{
|
||||
return printer.Print(this);
|
||||
}
|
||||
|
||||
internal static DbQueryCommandTree FromValidExpression(MetadataWorkspace metadata, DataSpace dataSpace, DbExpression query)
|
||||
{
|
||||
#if DEBUG
|
||||
return new DbQueryCommandTree(metadata, dataSpace, query);
|
||||
#else
|
||||
return new DbQueryCommandTree(metadata, dataSpace, query, false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,94 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbSetClause.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Specifies a clause in a modification operation setting the value of a property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbSetClause : DbModificationClause
|
||||
{
|
||||
private DbExpression _prop;
|
||||
private DbExpression _val;
|
||||
|
||||
internal DbSetClause(DbExpression targetProperty, DbExpression sourceValue)
|
||||
: base()
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(targetProperty, "targetProperty");
|
||||
EntityUtil.CheckArgumentNull(sourceValue, "sourceValue");
|
||||
_prop = targetProperty;
|
||||
_val = sourceValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="DbExpression"/> that specifies the property that should be updated.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Constrained to be a <see cref="DbPropertyExpression"/>.
|
||||
/// </remarks>
|
||||
public DbExpression Property
|
||||
{
|
||||
get
|
||||
{
|
||||
return _prop;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="DbExpression"/> that specifies the new value with which to update the property.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Constrained to be a <see cref="DbConstantExpression"/> or <see cref="DbNullExpression"/>
|
||||
/// </remarks>
|
||||
public DbExpression Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _val;
|
||||
}
|
||||
}
|
||||
|
||||
internal override void DumpStructure(ExpressionDumper dumper)
|
||||
{
|
||||
dumper.Begin("DbSetClause");
|
||||
if (null != this.Property)
|
||||
{
|
||||
dumper.Dump(this.Property, "Property");
|
||||
}
|
||||
if (null != this.Value)
|
||||
{
|
||||
dumper.Dump(this.Value, "Value");
|
||||
}
|
||||
dumper.End("DbSetClause");
|
||||
}
|
||||
|
||||
internal override TreeNode Print(DbExpressionVisitor<TreeNode> visitor)
|
||||
{
|
||||
TreeNode node = new TreeNode("DbSetClause");
|
||||
if (null != this.Property)
|
||||
{
|
||||
node.Children.Add(new TreeNode("Property", this.Property.Accept(visitor)));
|
||||
}
|
||||
if (null != this.Value)
|
||||
{
|
||||
node.Children.Add(new TreeNode("Value", this.Value.Accept(visitor)));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,137 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="DbUpdateCommandTree.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....], [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Diagnostics;
|
||||
|
||||
using ReadOnlyModificationClauses = System.Collections.ObjectModel.ReadOnlyCollection<System.Data.Common.CommandTrees.DbModificationClause>; // System.Data.Common.ReadOnlyCollection conflicts
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a single-row update operation expressed as a canonical command tree.
|
||||
/// When the <see cref="Returning"/> property is set, the command returns a reader; otherwise,
|
||||
/// it returns a scalar indicating the number of rows affected.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbUpdateCommandTree : DbModificationCommandTree
|
||||
{
|
||||
private readonly DbExpression _predicate;
|
||||
private readonly DbExpression _returning;
|
||||
private readonly ReadOnlyModificationClauses _setClauses;
|
||||
|
||||
internal DbUpdateCommandTree(MetadataWorkspace metadata, DataSpace dataSpace, DbExpressionBinding target, DbExpression predicate, ReadOnlyModificationClauses setClauses, DbExpression returning)
|
||||
: base(metadata, dataSpace, target)
|
||||
{
|
||||
EntityUtil.CheckArgumentNull(predicate, "predicate");
|
||||
EntityUtil.CheckArgumentNull(setClauses, "setClauses");
|
||||
// returning is allowed to be null
|
||||
|
||||
this._predicate = predicate;
|
||||
this._setClauses = setClauses;
|
||||
this._returning = returning;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of update set clauses that define the update operation.
|
||||
/// </summary>
|
||||
public IList<DbModificationClause> SetClauses
|
||||
{
|
||||
get
|
||||
{
|
||||
return _setClauses;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="DbExpression"/> that specifies a projection of results to be returned based on the modified rows.
|
||||
/// If null, indicates no results should be returned from this command.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The returning projection includes only the following elements:
|
||||
/// <list>
|
||||
/// <item>NewInstance expression</item>
|
||||
/// <item>Property expression</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public DbExpression Returning
|
||||
{
|
||||
get
|
||||
{
|
||||
return _returning;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="DbExpression"/> that specifies the predicate used to determine which members of the target collection should be updated.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The predicate includes only the following elements:
|
||||
/// <list>
|
||||
/// <item>Equality expression</item>
|
||||
/// <item>Constant expression</item>
|
||||
/// <item>IsNull expression</item>
|
||||
/// <item>Property expression</item>
|
||||
/// <item>Reference expression to the target</item>
|
||||
/// <item>And expression</item>
|
||||
/// <item>Or expression</item>
|
||||
/// <item>Not expression</item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
public DbExpression Predicate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _predicate;
|
||||
}
|
||||
}
|
||||
|
||||
internal override DbCommandTreeKind CommandTreeKind
|
||||
{
|
||||
get { return DbCommandTreeKind.Update; }
|
||||
}
|
||||
|
||||
internal override bool HasReader
|
||||
{
|
||||
get { return null != Returning; }
|
||||
}
|
||||
|
||||
internal override void DumpStructure(ExpressionDumper dumper)
|
||||
{
|
||||
base.DumpStructure(dumper);
|
||||
|
||||
if (this.Predicate != null)
|
||||
{
|
||||
dumper.Dump(this.Predicate, "Predicate");
|
||||
}
|
||||
|
||||
dumper.Begin("SetClauses", null);
|
||||
foreach (DbModificationClause clause in this.SetClauses)
|
||||
{
|
||||
if (null != clause)
|
||||
{
|
||||
clause.DumpStructure(dumper);
|
||||
}
|
||||
}
|
||||
dumper.End("SetClauses");
|
||||
|
||||
dumper.Dump(this.Returning, "Returning");
|
||||
}
|
||||
|
||||
internal override string PrintTree(ExpressionPrinter printer)
|
||||
{
|
||||
return printer.Print(this);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,139 @@
|
||||
//---------------------------------------------------------------------
|
||||
// <copyright file="ExpressionBindings.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
//
|
||||
// @owner [....]
|
||||
// @backupOwner [....]
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
|
||||
using System.Data.Common;
|
||||
using System.Data.Common.Utils;
|
||||
using System.Data.Metadata.Edm;
|
||||
using System.Data.Common.CommandTrees.Internal;
|
||||
using System.Data.Common.CommandTrees.ExpressionBuilder;
|
||||
|
||||
namespace System.Data.Common.CommandTrees
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes a binding for an expression. Conceptually similar to a foreach loop
|
||||
/// in C#. The DbExpression property defines the collection being iterated over,
|
||||
/// while the Var property provides a means to reference the current element
|
||||
/// of the collection during the iteration. DbExpressionBinding is used to describe the set arguments
|
||||
/// to relational expressions such as <see cref="DbFilterExpression"/>, <see cref="DbProjectExpression"/>
|
||||
/// and <see cref="DbJoinExpression"/>.
|
||||
/// </summary>
|
||||
/// <seealso cref="DbExpression"/>
|
||||
/// <seealso cref="Variable"/>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbExpressionBinding
|
||||
{
|
||||
private readonly DbExpression _expr;
|
||||
private readonly DbVariableReferenceExpression _varRef;
|
||||
|
||||
internal DbExpressionBinding(DbExpression input, DbVariableReferenceExpression varRef)
|
||||
{
|
||||
Debug.Assert(input != null, "DbExpressionBinding input cannot be null");
|
||||
Debug.Assert(varRef != null, "DbExpressionBinding variable cannot be null");
|
||||
|
||||
_expr = input;
|
||||
_varRef = varRef;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DbExpression"/> that defines the input set.
|
||||
/// </summary>
|
||||
public DbExpression Expression { get { return _expr; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name assigned to the element variable.
|
||||
/// </summary>
|
||||
public string VariableName { get { return _varRef.VariableName; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type metadata of the element variable.
|
||||
/// </summary>
|
||||
public TypeUsage VariableType { get { return _varRef.ResultType; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DbVariableReferenceExpression"/> that references the element variable.
|
||||
/// </summary>
|
||||
public DbVariableReferenceExpression Variable { get { return _varRef;} }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the binding for the input set to a <see cref="DbGroupByExpression"/>.
|
||||
/// In addition to the properties of <see cref="DbExpressionBinding"/>, DbGroupExpressionBinding
|
||||
/// also provides access to the group element via the <seealso cref="GroupVariable"/> variable reference
|
||||
/// and to the group aggregate via the <seealso cref="GroupAggregate"/> property.
|
||||
/// </summary>
|
||||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Db")]
|
||||
public sealed class DbGroupExpressionBinding
|
||||
{
|
||||
private /*readonly*/ DbExpression _expr;
|
||||
private readonly DbVariableReferenceExpression _varRef;
|
||||
private readonly DbVariableReferenceExpression _groupVarRef;
|
||||
private DbGroupAggregate _groupAggregate;
|
||||
|
||||
internal DbGroupExpressionBinding(DbExpression input, DbVariableReferenceExpression inputRef, DbVariableReferenceExpression groupRef)
|
||||
{
|
||||
_expr = input;
|
||||
_varRef = inputRef;
|
||||
_groupVarRef = groupRef;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="DbExpression"/> that defines the input set.
|
||||
/// </summary>
|
||||
public DbExpression Expression { get { return _expr; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name assigned to the element variable.
|
||||
/// </summary>
|
||||
public string VariableName { get { return _varRef.VariableName; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type metadata of the element variable.
|
||||
/// </summary>
|
||||
public TypeUsage VariableType { get { return _varRef.ResultType; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DbVariableReferenceExpression that references the element variable.
|
||||
/// </summary>
|
||||
public DbVariableReferenceExpression Variable { get { return _varRef; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name assigned to the group element variable.
|
||||
/// </summary>
|
||||
public string GroupVariableName { get { return _groupVarRef.VariableName; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the type metadata of the group element variable.
|
||||
/// </summary>
|
||||
public TypeUsage GroupVariableType { get { return _groupVarRef.ResultType; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DbVariableReferenceExpression that references the group element variable.
|
||||
/// </summary>
|
||||
public DbVariableReferenceExpression GroupVariable { get { return _groupVarRef; } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the DbGroupAggregate that represents the collection of elements of the group.
|
||||
/// </summary>
|
||||
public DbGroupAggregate GroupAggregate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_groupAggregate == null)
|
||||
{
|
||||
_groupAggregate = DbExpressionBuilder.GroupAggregate(this.GroupVariable);
|
||||
}
|
||||
return _groupAggregate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1 @@
|
||||
018822d2543b4f4203990b783596318b13f64e32
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user