本文整理汇总了C#中System.Data.Entity.Core.Query.InternalTrees.Var类的典型用法代码示例。如果您正苦于以下问题:C# Var类的具体用法?C# Var怎么用?C# Var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Var类属于System.Data.Entity.Core.Query.InternalTrees命名空间,在下文中一共展示了Var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStructuredVarInfo
/// <summary>
/// Create a new VarInfo for a structured type Var
/// </summary>
/// <param name="v"> The structured type Var </param>
/// <param name="newType"> "Mapped" type for v </param>
/// <param name="newVars"> List of vars corresponding to v </param>
/// <param name="newProperties"> Flattened Properties </param>
/// <param name="newVarsIncludeNullSentinelVar"> Do the new vars include a var that represents a null sentinel either for this type or for any nested type </param>
/// <returns> the VarInfo </returns>
internal VarInfo CreateStructuredVarInfo(
Var v, RowType newType, List<Var> newVars, List<EdmProperty> newProperties, bool newVarsIncludeNullSentinelVar)
{
VarInfo varInfo = new StructuredVarInfo(newType, newVars, newProperties, newVarsIncludeNullSentinelVar);
m_map.Add(v, varInfo);
return varInfo;
}
示例2: PrimitiveTypeVarInfo
private readonly List<Var> m_newVars; // always a singleton list
/// <summary>
/// Initializes a new instance of <see cref="PrimitiveTypeVarInfo" /> class.
/// </summary>
/// <param name="newVar">
/// New <see cref="Var" /> that replaces current <see cref="Var" /> .
/// </param>
internal PrimitiveTypeVarInfo(Var newVar)
{
DebugCheck.NotNull(newVar);
m_newVars = new List<Var>
{
newVar
};
}
示例3: PrimitiveTypeVarInfo
private readonly List<Var> m_newVars; // always a singleton list
/// <summary>
/// Initializes a new instance of <see cref="PrimitiveTypeVarInfo"/> class.
/// </summary>
/// <param name="newVar">
/// New <see cref="Var"/> that replaces current <see cref="Var"/>.
/// </param>
internal PrimitiveTypeVarInfo(Var newVar)
{
Debug.Assert(newVar != null, "newVar != null");
m_newVars = new List<Var>
{
newVar
};
}
示例4: IsVarRefOverGivenVar
/// <summary>
/// Determines whether the given node is a VarRef over the given var
/// </summary>
/// <param name="node"> </param>
/// <param name="var"> </param>
/// <returns> </returns>
internal static bool IsVarRefOverGivenVar(Node node, Var var)
{
if (node.Op.OpType
!= OpType.VarRef)
{
return false;
}
return ((VarRefOp)node.Op).Var == var;
}
示例5: AddSubqueryToParentRelOp
protected Node AddSubqueryToParentRelOp(Var outputVar, Node subquery)
{
var ancestor = FindRelOpAncestor();
PlanCompiler.Assert(ancestor != null, "no ancestors found?");
AddSubqueryToRelOpNode(ancestor, subquery);
subquery = m_command.CreateNode(m_command.CreateVarRefOp(outputVar));
return subquery;
}
示例6: CollectionInfo
internal CollectionInfo(
Var collectionVar, ColumnMap columnMap, VarList flattenedElementVars, VarVec keys, List<SortKey> sortKeys,
object discriminatorValue)
{
m_collectionVar = collectionVar;
m_columnMap = columnMap;
m_flattenedElementVars = flattenedElementVars;
m_keys = keys;
m_sortKeys = sortKeys;
m_discriminatorValue = discriminatorValue;
}
示例7: CreatePrimitiveTypeVarInfo
internal VarInfo CreatePrimitiveTypeVarInfo(Var v, Var newVar)
{
DebugCheck.NotNull(v);
DebugCheck.NotNull(newVar);
PlanCompiler.Assert(TypeSemantics.IsScalarType(v.Type), "The current variable should be of primitive or enum type.");
PlanCompiler.Assert(TypeSemantics.IsScalarType(newVar.Type), "The new variable should be of primitive or enum type.");
VarInfo varInfo = new PrimitiveTypeVarInfo(newVar);
m_map.Add(v, varInfo);
return varInfo;
}
示例8: Add
// <summary>
// Add an entry that the given property of the given var is a computation represented
// by the computationTemplate over the var represented by the given groupAggregateVarInfo
// </summary>
internal void Add(
Var var, GroupAggregateVarInfo groupAggregateVarInfo, Node computationTemplate, bool isUnnested, EdmMember property)
{
if (property == null)
{
Add(var, groupAggregateVarInfo, computationTemplate, isUnnested);
return;
}
if (_groupAggregateVarRelatedVarPropertyToInfo == null)
{
_groupAggregateVarRelatedVarPropertyToInfo = new Dictionary<Var, Dictionary<EdmMember, GroupAggregateVarRefInfo>>();
}
Dictionary<EdmMember, GroupAggregateVarRefInfo> varPropertyDictionary;
if (!_groupAggregateVarRelatedVarPropertyToInfo.TryGetValue(var, out varPropertyDictionary))
{
varPropertyDictionary = new Dictionary<EdmMember, GroupAggregateVarRefInfo>();
_groupAggregateVarRelatedVarPropertyToInfo.Add(var, varPropertyDictionary);
}
varPropertyDictionary.Add(property, new GroupAggregateVarRefInfo(groupAggregateVarInfo, computationTemplate, isUnnested));
// Note: The following line is not necessary with the current usage pattern, this method is
// never called with a new groupAggregateVarInfo thus it is a no-op.
_groupAggregateVarInfos.Add(groupAggregateVarInfo);
}
示例9: BuildNullIfExpression
/// <summary>
/// Builds a NULLIF expression (ie) a Case expression that looks like
/// CASE WHEN v is null THEN null ELSE expr END
/// where v is the conditionVar parameter, and expr is the value of the expression
/// when v is non-null
/// </summary>
/// <param name="conditionVar"> null discriminator var </param>
/// <param name="expr"> expression </param>
/// <returns> </returns>
internal Node BuildNullIfExpression(Var conditionVar, Node expr)
{
var varRefOp = Command.CreateVarRefOp(conditionVar);
var varRefNode = Command.CreateNode(varRefOp);
var whenNode = Command.CreateNode(Command.CreateConditionalOp(OpType.IsNull), varRefNode);
var elseNode = expr;
var thenNode = Command.CreateNode(Command.CreateNullOp(elseNode.Op.Type));
var caseNode = Command.CreateNode(Command.CreateCaseOp(elseNode.Op.Type), whenNode, thenNode, elseNode);
return caseNode;
}
示例10: IsNonNullable
/// <summary>
/// Is the given var guaranteed to be non-nullable with regards to the node
/// that is currently being processed.
/// True, if it is listed as such on any on the node infos on any of the
/// current relop ancestors.
/// </summary>
/// <param name="var"> </param>
/// <returns> </returns>
internal bool IsNonNullable(Var var)
{
foreach (var relOpAncestor in m_relOpAncestors)
{
// Rules applied to the children of the relOpAncestor may have caused it change.
// Thus, if the node is used, it has to have its node info recomputed
Command.RecomputeNodeInfo(relOpAncestor);
var nodeInfo = Command.GetExtendedNodeInfo(relOpAncestor);
if (nodeInfo.NonNullableVisibleDefinitions.IsSet(var))
{
return true;
}
else if (nodeInfo.LocalDefinitions.IsSet(var))
{
//The var is defined on this ancestor but is not non-nullable,
// therefore there is no need to further check other ancestors
return false;
}
}
return false;
}
示例11: CollectionVarInfo
private readonly List<Var> m_newVars; // always a singleton list
/// <summary>
/// Create a CollectionVarInfo
/// </summary>
internal CollectionVarInfo(Var newVar)
{
m_newVars = new List<Var>();
m_newVars.Add(newVar);
}
示例12: RewriteFromOneNavigationProperty
private Node RewriteFromOneNavigationProperty(
RelProperty relProperty, List<RelationshipSet> relationshipSets, Node sourceRefNode, out Var outputVar)
{
PlanCompiler.Assert(relationshipSets.Count > 0, "expected at least one relationship set here");
PlanCompiler.Assert(
relProperty.FromEnd.RelationshipMultiplicity != RelationshipMultiplicity.Many,
"Expected source end multiplicity to be one. Found 'Many' instead " + relProperty);
var entityType = TypeHelpers.GetElementTypeUsage(relProperty.ToEnd.TypeUsage);
var scanTableNodes = new List<Node>(relationshipSets.Count);
var scanTableVars = new List<Var>(relationshipSets.Count);
foreach (var r in relationshipSets)
{
var entitySet = FindTargetEntitySet(r, relProperty.ToEnd);
Var tableVar;
var tableNode = BuildOfTypeTable(entitySet, entityType, out tableVar);
scanTableNodes.Add(tableNode);
scanTableVars.Add(tableVar);
}
//
// Build the union-all node
//
Node unionAllNode;
m_command.BuildUnionAllLadder(scanTableNodes, scanTableVars, out unionAllNode, out outputVar);
//
// Now build up the appropriate filter. Select out the relproperty from the other end
//
var inverseRelProperty = new RelProperty(relProperty.Relationship, relProperty.ToEnd, relProperty.FromEnd);
PlanCompiler.Assert(
m_command.IsRelPropertyReferenced(inverseRelProperty),
"Unreferenced rel property? " + inverseRelProperty);
var inverseRelPropertyNode = m_command.CreateNode(
m_command.CreateRelPropertyOp(inverseRelProperty),
m_command.CreateNode(m_command.CreateVarRefOp(outputVar)));
var predicateNode = m_command.BuildComparison(
OpType.EQ,
sourceRefNode, inverseRelPropertyNode);
var ret = m_command.CreateNode(m_command.CreateFilterOp(), unionAllNode, predicateNode);
return ret;
}
示例13: CapWithIsNotNullFilter
// <summary>
// Input => Filter(input, Ref(var) is not null)
// </summary>
private Node CapWithIsNotNullFilter(Node input, Var var)
{
var varRefNode = Command.CreateNode(Command.CreateVarRefOp(var));
var predicateNode = Command.CreateNode(
Command.CreateConditionalOp(OpType.Not),
Command.CreateNode(
Command.CreateConditionalOp(OpType.IsNull),
varRefNode));
var filterNode = Command.CreateNode(Command.CreateFilterOp(), input, predicateNode);
return filterNode;
}
示例14: AugmentNodeWithInternalIntegerConstant
// <summary>
// 'Extend' a given input node to also project out an internal integer constant with the given value
// </summary>
private Node AugmentNodeWithInternalIntegerConstant(Node input, int value, out Var internalConstantVar)
{
return AugmentNodeWithConstant(
input, () => Command.CreateInternalConstantOp(Command.IntegerType, value), out internalConstantVar);
}
示例15: ConvertToNestOpInput
// <summary>
// Convert a CollectOp subtree (when used as the defining expression for a
// VarDefOp) into a reasonable input to a NestOp.
// </summary>
// <remarks>
// There are a couple of cases that we handle here:
// (a) PhysicalProject(X) ==> X
// (b) PhysicalProject(Sort(X)) ==> Sort(X)
// </remarks>
// <param name="physicalProjectNode"> the child of the CollectOp </param>
// <param name="collectionVar"> the collectionVar being defined </param>
// <param name="collectionInfoList"> where to append the new collectionInfo </param>
// <param name="collectionNodes"> where to append the collectionNode </param>
// <param name="externalReferences"> a bit vector of external references of the physicalProject </param>
// <param name="collectionReferences"> a bit vector of collection vars </param>
private void ConvertToNestOpInput(
Node physicalProjectNode, Var collectionVar, List<CollectionInfo> collectionInfoList, List<Node> collectionNodes,
VarVec externalReferences, VarVec collectionReferences)
{
// Keep track of any external references the physicalProjectOp has
externalReferences.Or(Command.GetNodeInfo(physicalProjectNode).ExternalReferences);
// Case: (a) PhysicalProject(X) ==> X
var nestOpInput = physicalProjectNode.Child0;
// Now build the collectionInfo for this input, including the flattened
// list of vars, which is essentially the outputs from the physicalProject
// with the sortKey vars that aren't already in the outputs we already
// have.
var physicalProjectOp = (PhysicalProjectOp)physicalProjectNode.Op;
var flattenedElementVarList = Command.CreateVarList(physicalProjectOp.Outputs);
var flattenedElementVarVec = Command.CreateVarVec(flattenedElementVarList); // Use a VarVec to make the lookups faster
List<SortKey> sortKeys = null;
if (OpType.Sort
== nestOpInput.Op.OpType)
{
// Case: (b) PhysicalProject(Sort(X)) ==> Sort(X)
var sortOp = (SortOp)nestOpInput.Op;
sortKeys = OpCopier.Copy(Command, sortOp.Keys);
foreach (var sk in sortKeys)
{
if (!flattenedElementVarVec.IsSet(sk.Var))
{
flattenedElementVarList.Add(sk.Var);
flattenedElementVarVec.Set(sk.Var);
}
}
}
else
{
sortKeys = new List<SortKey>();
}
// Get the keys for the collection
var keyVars = Command.GetExtendedNodeInfo(nestOpInput).Keys.KeyVars;
//Check whether all key are projected
var keyVarsClone = keyVars.Clone();
keyVarsClone.Minus(flattenedElementVarVec);
var keys = (keyVarsClone.IsEmpty) ? keyVars.Clone() : Command.CreateVarVec();
// Create the collectionInfo
var collectionInfo = Command.CreateCollectionInfo(
collectionVar, physicalProjectOp.ColumnMap.Element, flattenedElementVarList, keys, sortKeys, null /*discriminatorValue*/);
// Now update the collections we're tracking.
collectionInfoList.Add(collectionInfo);
collectionNodes.Add(nestOpInput);
collectionReferences.Set(collectionVar);
}