本文整理汇总了C#中BoolExpression类的典型用法代码示例。如果您正苦于以下问题:C# BoolExpression类的具体用法?C# BoolExpression怎么用?C# BoolExpression使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BoolExpression类属于命名空间,在下文中一共展示了BoolExpression类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Then
public Then(BoolExpression condition, Action thenAction, Action elseAction, object cookie)
{
this.condition=condition;
this.thenAction=thenAction;
this.elseAction=elseAction;
this.cookie=cookie;
}
开发者ID:brandongrossutti,项目名称:DotCopter,代码行数:7,代码来源:If.cs
示例2: CqlBlock
/// <summary>
/// Initializes a <see cref="CqlBlock"/> with the SELECT (<paramref name="slotInfos"/>), FROM (<paramref name="children"/>),
/// WHERE (<paramref name="whereClause"/>), AS (<paramref name="blockAliasNum"/>).
/// </summary>
protected CqlBlock(SlotInfo[] slotInfos, List<CqlBlock> children, BoolExpression whereClause, CqlIdentifiers identifiers, int blockAliasNum)
{
m_slots = new ReadOnlyCollection<SlotInfo>(slotInfos);
m_children = new ReadOnlyCollection<CqlBlock>(children);
m_whereClause = whereClause;
m_blockAlias = identifiers.GetBlockAlias(blockAliasNum);
}
开发者ID:uQr,项目名称:referencesource,代码行数:11,代码来源:CqlBlock.cs
示例3: BooleanProjectedSlot
/// <summary>
/// Creates a boolean slot for expression that comes from originalCellNum, i.e.,
/// the value of the slot is <paramref name="expr"/> and the name is "_from{<paramref name="originalCellNum"/>}", e.g., _from2
/// </summary>
internal BooleanProjectedSlot(BoolExpression expr, CqlIdentifiers identifiers, int originalCellNum)
{
m_expr = expr;
m_originalCell = new CellIdBoolean(identifiers, originalCellNum);
Debug.Assert(!(expr.AsLiteral is CellIdBoolean) ||
BoolLiteral.EqualityComparer.Equals((CellIdBoolean)expr.AsLiteral, m_originalCell), "Cellid boolean for the slot and cell number disagree");
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:12,代码来源:BooleanProjectedSlot.cs
示例4: ExtentCqlBlock
/// <summary>
/// Creates an cql block representing the <paramref name="extent"/> (the FROM part).
/// SELECT is given by <paramref name="slots"/>, WHERE by <paramref name="whereClause"/> and AS by <paramref name="blockAliasNum"/>.
/// </summary>
internal ExtentCqlBlock(EntitySetBase extent,
CellQuery.SelectDistinct selectDistinct,
SlotInfo[] slots,
BoolExpression whereClause,
CqlIdentifiers identifiers,
int blockAliasNum)
: base(slots, EmptyChildren, whereClause, identifiers, blockAliasNum)
{
m_extent = extent;
m_nodeTableAlias = identifiers.GetBlockAlias();
m_selectDistinct = selectDistinct;
}
开发者ID:uQr,项目名称:referencesource,代码行数:16,代码来源:ExtentCqlBlock.cs
示例5: CellQuery
// effects: Given all the fields, just sets them.
internal CellQuery(
ProjectedSlot[] projectedSlots,
BoolExpression whereClause,
List<BoolExpression> boolExprs,
SelectDistinct elimDupl, MemberPath rootMember)
{
m_boolExprs = boolExprs;
m_projectedSlots = projectedSlots;
m_whereClause = whereClause;
m_originalWhereClause = whereClause;
m_selectDistinct = elimDupl;
m_extentMemberPath = rootMember;
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:14,代码来源:CellQuery.cs
示例6: CqlGenerator
/// <summary>
/// Given the generated <paramref name="view"/>, the <paramref name="caseStatements"/> for the multiconstant fields,
/// the <paramref name="projectedSlotMap"/> that maps different paths of the entityset (for which the view is being generated) to slot indexes in the view,
/// creates an object that is capable of generating the Cql for <paramref name="view"/>.
/// </summary>
internal CqlGenerator(CellTreeNode view,
Dictionary<MemberPath,
CaseStatement> caseStatements,
CqlIdentifiers identifiers,
MemberProjectionIndex projectedSlotMap,
int numCellsInView,
BoolExpression topLevelWhereClause,
StorageMappingItemCollection mappingItemCollection)
{
m_view = view;
m_caseStatements = caseStatements;
m_projectedSlotMap = projectedSlotMap;
m_numBools = numCellsInView; // We have that many booleans
m_topLevelWhereClause = topLevelWhereClause;
m_identifiers = identifiers;
m_mappingItemCollection = mappingItemCollection;
}
开发者ID:uQr,项目名称:referencesource,代码行数:22,代码来源:CqlGenerator.cs
示例7: CaseCqlBlock
internal CaseCqlBlock(
SlotInfo[] slots, int caseSlot, CqlBlock child, BoolExpression whereClause, CqlIdentifiers identifiers, int blockAliasNum)
: base(slots, new List<CqlBlock>(new[] { child }), whereClause, identifiers, blockAliasNum)
{
m_caseSlotInfo = slots[caseSlot];
}
开发者ID:hallco978,项目名称:entityframework,代码行数:6,代码来源:CaseCqlBlock.cs
示例8: While
public While(BoolExpression condition)
{
this.condition=condition;
this.cookie=FuncBuilder.Instance.StartInflightUtterance("While requires a Do");
}
开发者ID:brandongrossutti,项目名称:DotCopter,代码行数:5,代码来源:While.cs
示例9: ExtractProperties
// requires: "properties" corresponds to all the properties that are
// inside cNode.Value, e.g., cNode corresponds to an extent Person,
// properties contains all the properties inside Person (recursively)
// effects: Given C-side and S-side Cell Query for a cell, generates
// the projected slots on both sides corresponding to
// properties. Also updates the C-side whereclause corresponding to
// discriminator properties on the C-side, e.g, isHighPriority
private void ExtractProperties(
IEnumerable<StoragePropertyMapping> properties,
MemberPath cNode, List<ProjectedSlot> cSlots,
ref BoolExpression cQueryWhereClause,
MemberPath sRootExtent,
List<ProjectedSlot> sSlots,
ref BoolExpression sQueryWhereClause)
{
// For each property mapping, we add an entry to the C and S cell queries
foreach (var propMap in properties)
{
var scalarPropMap = propMap as StorageScalarPropertyMapping;
var complexPropMap = propMap as StorageComplexPropertyMapping;
var associationEndPropertypMap = propMap as StorageEndPropertyMapping;
var conditionMap = propMap as StorageConditionPropertyMapping;
Debug.Assert(
scalarPropMap != null ||
complexPropMap != null ||
associationEndPropertypMap != null ||
conditionMap != null, "Unimplemented property mapping");
if (scalarPropMap != null)
{
Debug.Assert(scalarPropMap.ColumnProperty != null, "ColumnMember for a Scalar Property can not be null");
// Add an attribute node to node
var cAttributeNode = new MemberPath(cNode, scalarPropMap.EdmProperty);
// Add a column (attribute) node the sQuery
// unlike the C side, there is no nesting. Hence we
// did not need an internal node
var sAttributeNode = new MemberPath(sRootExtent, scalarPropMap.ColumnProperty);
cSlots.Add(new MemberProjectedSlot(cAttributeNode));
sSlots.Add(new MemberProjectedSlot(sAttributeNode));
}
// Note: S-side constants are not allowed since they can cause
// problems -- for example, if such a cell says 5 for the
// third field, we cannot guarantee the fact that an
// application may not set that field to 7 in the C-space
// Check if the property mapping is for a complex types
if (complexPropMap != null)
{
foreach (var complexTypeMap in complexPropMap.TypeMappings)
{
// Create a node for the complex type property and call recursively
var complexMemberNode = new MemberPath(cNode, complexPropMap.EdmProperty);
//Get the list of types that this type map represents
var allTypes = new Set<EdmType>();
// Gather a set of all explicit types for an entity
// type mapping in allTypes.
var exactTypes = Helpers.AsSuperTypeList<ComplexType, EdmType>(complexTypeMap.Types);
allTypes.AddRange(exactTypes);
foreach (EdmType type in complexTypeMap.IsOfTypes)
{
allTypes.AddRange(
MetadataHelper.GetTypeAndSubtypesOf(
type, m_containerMapping.StorageMappingItemCollection.EdmItemCollection, false /*includeAbstractTypes*/));
}
var complexInTypes = BoolExpression.CreateLiteral(new TypeRestriction(complexMemberNode, allTypes), null);
cQueryWhereClause = BoolExpression.CreateAnd(cQueryWhereClause, complexInTypes);
// Now extract the properties of the complex type
// (which could have other complex types)
ExtractProperties(
complexTypeMap.AllProperties, complexMemberNode, cSlots,
ref cQueryWhereClause, sRootExtent, sSlots, ref sQueryWhereClause);
}
}
// Check if the property mapping is for an associaion
if (associationEndPropertypMap != null)
{
// create join tree node representing this relation end
var associationEndNode = new MemberPath(cNode, associationEndPropertypMap.EndMember);
// call recursively
ExtractProperties(
associationEndPropertypMap.Properties, associationEndNode, cSlots,
ref cQueryWhereClause, sRootExtent, sSlots, ref sQueryWhereClause);
}
//Check if the this is a condition and add it to the Where clause
if (conditionMap != null)
{
if (conditionMap.ColumnProperty != null)
{
//Produce a Condition Expression for the Condition Map.
var conditionExpression = GetConditionExpression(sRootExtent, conditionMap);
//Add the condition expression to the exisiting S side Where clause using an "And"
sQueryWhereClause = BoolExpression.CreateAnd(sQueryWhereClause, conditionExpression);
}
else
{
//.........这里部分代码省略.........
开发者ID:christiandpena,项目名称:entityframework,代码行数:101,代码来源:CellCreator.cs
示例10: FindRewritingAndUsedViews
// Find rewriting for query SELECT <attributes> WHERE <whereClause> FROM _extentPath
// and add view appearing in rewriting to outputUsedViews
private bool FindRewritingAndUsedViews(
IEnumerable<MemberPath> attributes, BoolExpression whereClause,
HashSet<FragmentQuery> outputUsedViews, out Tile<FragmentQuery> rewriting)
{
IEnumerable<MemberPath> notCoveredAttributes;
return FindRewritingAndUsedViews(
attributes, whereClause, outputUsedViews, out rewriting,
out notCoveredAttributes);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:QueryRewriter.cs
示例11: UpdateWhereClause
// requires: The CellConstantDomains in the OneOfConsts of the where
// clause are partially done
// effects: Given the domains of different variables in domainMap,
// fixes the whereClause of this such that all the
// CellConstantDomains in OneOfConsts are complete
internal void UpdateWhereClause(MemberDomainMap domainMap)
{
var atoms = new List<BoolExpression>();
foreach (var atom in WhereClause.Atoms)
{
var literal = atom.AsLiteral;
var restriction = literal as MemberRestriction;
Debug.Assert(restriction != null, "All bool literals must be OneOfConst at this point");
// The oneOfConst needs to be fixed with the new possible values from the domainMap.
var possibleValues = domainMap.GetDomain(restriction.RestrictedMemberSlot.MemberPath);
var newOneOf = restriction.CreateCompleteMemberRestriction(possibleValues);
// Prevent optimization of single constraint e.g: "300 in (300)"
// But we want to optimize type constants e.g: "category in (Category)"
// To prevent optimization of bool expressions we add a Sentinel OneOF
var scalarConst = restriction as ScalarRestriction;
var addSentinel =
scalarConst != null &&
!scalarConst.Domain.Contains(Constant.Null) &&
!scalarConst.Domain.Contains(Constant.NotNull) &&
!scalarConst.Domain.Contains(Constant.Undefined);
if (addSentinel)
{
domainMap.AddSentinel(newOneOf.RestrictedMemberSlot.MemberPath);
}
atoms.Add(BoolExpression.CreateLiteral(newOneOf, domainMap));
if (addSentinel)
{
domainMap.RemoveSentinel(newOneOf.RestrictedMemberSlot.MemberPath);
}
}
// We create a new whereClause that has the memberDomainMap set
if (atoms.Count > 0)
{
m_whereClause = BoolExpression.CreateAnd(atoms.ToArray());
}
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:46,代码来源:CellQuery.cs
示例12: EnsureConfigurationIsFullyMapped
// make sure that we can find a rewriting for each possible entity shape appearing in an extent
// Possible optimization for OfType view generation:
// Cache "used views" for each (currentPath, domainValue) combination
private void EnsureConfigurationIsFullyMapped(
MemberPath currentPath,
BoolExpression currentWhereClause,
HashSet<FragmentQuery> outputUsedViews,
ErrorLog errorLog)
{
foreach (var domainValue in GetDomain(currentPath))
{
if (domainValue == Constant.Undefined)
{
continue; // no point in trying to recover a situation that can never happen
}
TraceVerbose("REWRITING FOR {0}={1}", currentPath, domainValue);
// construct WHERE clause for this value
var domainAddedWhereClause = CreateMemberCondition(currentPath, domainValue);
// AND the current where clause to it
var domainWhereClause = BoolExpression.CreateAnd(currentWhereClause, domainAddedWhereClause);
// first check whether we can recover instances of this type - don't care about the attributes - to produce a helpful error message
Tile<FragmentQuery> rewriting;
if (false == FindRewritingAndUsedViews(_keyAttributes, domainWhereClause, outputUsedViews, out rewriting))
{
if (!ErrorPatternMatcher.FindMappingErrors(_context, _domainMap, _errorLog))
{
var builder = new StringBuilder();
var extentName = StringUtil.FormatInvariant("{0}", _extentPath);
var whereClause = rewriting.Query.Condition;
whereClause.ExpensiveSimplify();
if (whereClause.RepresentsAllTypeConditions)
{
var tableString = Strings.ViewGen_Extent;
builder.AppendLine(Strings.ViewGen_Cannot_Recover_Types(tableString, extentName));
}
else
{
var entitiesString = Strings.ViewGen_Entities;
builder.AppendLine(Strings.ViewGen_Cannot_Disambiguate_MultiConstant(entitiesString, extentName));
}
RewritingValidator.EntityConfigurationToUserString(whereClause, builder);
var record = new ErrorLog.Record(
ViewGenErrorCode.AmbiguousMultiConstants, builder.ToString(), _context.AllWrappersForExtent, String.Empty);
errorLog.AddEntry(record);
}
}
else
{
var typeConstant = domainValue as TypeConstant;
if (typeConstant != null)
{
// we are enumerating types
var edmType = typeConstant.EdmType;
// If can recover the type, make sure can get all the necessary attributes (key is included for EntityTypes)
var nonConditionalAttributes =
GetNonConditionalScalarMembers(edmType, currentPath, _domainMap).Union(
GetNonConditionalComplexMembers(edmType, currentPath, _domainMap)).ToList();
IEnumerable<MemberPath> notCoverdAttributes;
if (nonConditionalAttributes.Count > 0
&&
!FindRewritingAndUsedViews(
nonConditionalAttributes, domainWhereClause, outputUsedViews, out rewriting, out notCoverdAttributes))
{
//Error: No mapping specified for some attributes
// remove keys
nonConditionalAttributes = new List<MemberPath>(nonConditionalAttributes.Where(a => !a.IsPartOfKey));
Debug.Assert(nonConditionalAttributes.Count > 0, "Must have caught key-only case earlier");
AddUnrecoverableAttributesError(notCoverdAttributes, domainAddedWhereClause, errorLog);
}
else
{
// recurse into complex members
foreach (var complexMember in GetConditionalComplexMembers(edmType, currentPath, _domainMap))
{
EnsureConfigurationIsFullyMapped(complexMember, domainWhereClause, outputUsedViews, errorLog);
}
// recurse into scalar members
foreach (var scalarMember in GetConditionalScalarMembers(edmType, currentPath, _domainMap))
{
EnsureConfigurationIsFullyMapped(scalarMember, domainWhereClause, outputUsedViews, errorLog);
}
}
}
}
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:90,代码来源:QueryRewriter.cs
示例13: If
public If(BoolExpression condition)
{
this.condition=condition;
this.cookie=FuncBuilder.Instance.StartInflightUtterance("If requires an Endif");
}
开发者ID:brandongrossutti,项目名称:DotCopter,代码行数:5,代码来源:If.cs
示例14: WithOptionalElse
public WithOptionalElse(BoolExpression condition, Action thenAction, Action elseAction, object cookie)
: base(condition, thenAction, elseAction, cookie)
{
}
开发者ID:brandongrossutti,项目名称:DotCopter,代码行数:4,代码来源:If.cs
示例15: AddUnrecoverableAttributesError
private void AddUnrecoverableAttributesError(
IEnumerable<MemberPath> attributes, BoolExpression domainAddedWhereClause, ErrorLog errorLog)
{
var builder = new StringBuilder();
var extentName = StringUtil.FormatInvariant("{0}", _extentPath);
var tableString = Strings.ViewGen_Extent;
var attributesString = StringUtil.ToCommaSeparatedString(GetTypeBasedMemberPathList(attributes));
builder.AppendLine(Strings.ViewGen_Cannot_Recover_Attributes(attributesString, tableString, extentName));
RewritingValidator.EntityConfigurationToUserString(domainAddedWhereClause, builder);
var record = new ErrorLog.Record(
ViewGenErrorCode.AttributesUnrecoverable, builder.ToString(), _context.AllWrappersForExtent, String.Empty);
errorLog.AddEntry(record);
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:13,代码来源:QueryRewriter.cs
示例16: GenerateViewComponents
// Generates the components used to assemble and validate the view:
// (1) case statements
// (2) top-level where clause
// (3) used cells
// (4) basic view CellTreeNode
// (5) dictionary<MemberValue, CellTreeNode> for validation
internal void GenerateViewComponents()
{
// make sure everything is mapped (for query views only)
EnsureExtentIsFullyMapped(_usedViews);
// (1) case statements
GenerateCaseStatements(_domainMap.ConditionMembers(_extentPath.Extent), _usedViews);
AddTrivialCaseStatementsForConditionMembers();
if (_usedViews.Count == 0
|| _errorLog.Count > 0)
{
// can't continue: no view will be generated, further validation doesn't make sense
Debug.Assert(_errorLog.Count > 0);
ExceptionHelpers.ThrowMappingException(_errorLog, _config);
}
// (2) top-level where clause
_topLevelWhereClause = GetTopLevelWhereClause(_usedViews);
// some tracing
if (_context.ViewTarget
== ViewTarget.QueryView)
{
TraceVerbose("Used {0} views of {1} total for rewriting", _usedViews.Count, _views.Count);
}
PrintStatistics(_qp);
// (3) construct the final _from variables
_usedCells = RemapFromVariables();
// (4) construct basic view
var basicViewGenerator = new BasicViewGenerator(
_context.MemberMaps.ProjectedSlotMap, _usedCells,
_domainQuery, _context, _domainMap, _errorLog, _config);
_basicView = basicViewGenerator.CreateViewExpression();
// a top-level WHERE clause is needed only if the simplifiedView still contains extra tuples
var noWhereClauseNeeded = _context.LeftFragmentQP.IsContainedIn(_basicView.LeftFragmentQuery, _domainQuery);
if (noWhereClauseNeeded)
{
_topLevelWhereClause = BoolExpression.True;
}
if (_errorLog.Count > 0)
{
ExceptionHelpers.ThrowMappingException(_errorLog, _config);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:57,代码来源:QueryRewriter.cs
示例17: FindRewriting
// Find rewriting for query SELECT <attributes> WHERE <whereClause> FROM _extentPath
private bool FindRewriting(
IEnumerable<MemberPath> attributes, BoolExpression whereClause,
out Tile<FragmentQuery> rewriting, out IEnumerable<MemberPath> notCoveredAttributes)
{
Tile<FragmentQuery> toFill = CreateTile(FragmentQuery.Create(attributes, whereClause));
Debug.Assert(toFill.Query.Attributes.Count > 0, "Query has no attributes?");
Tile<FragmentQuery> toAvoid = CreateTile(FragmentQuery.Create(_keyAttributes, BoolExpression.CreateNot(whereClause)));
var isRelaxed = (_context.ViewTarget == ViewTarget.UpdateView);
var found = RewriteQuery(toFill, toAvoid, out rewriting, out notCoveredAttributes, isRelaxed);
Debug.Assert(
!found || rewriting.GetNamedQueries().All(q => q != _trueViewSurrogate.Query),
"TrueViewSurrogate should have been substituted");
return found;
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:16,代码来源:QueryRewriter.cs
示例18: MergeBoolExpressions
MergeBoolExpressions(CellQuery query1, CellQuery query2,
BoolExpression conjunct1, BoolExpression conjunct2, CellTreeOpType opType)
{
List<BoolExpression> bools1 = query1.BoolVars;
List<BoolExpression> bools2 = query2.BoolVars;
// Add conjuncts to both sets if needed
if (false == conjunct1.IsTrue)
{
bools1 = BoolExpression.AddConjunctionToBools(bools1, conjunct1);
}
if (false == conjunct2.IsTrue)
{
bools2 = BoolExpression.AddConjunctionToBools(bools2, conjunct2);
}
// Perform merge
Debug.Assert(bools1.Count == bools2.Count);
List<BoolExpression> bools = new List<BoolExpression>();
// Both bools1[i] and bools2[i] be null for some of the i's. When
// we merge two (leaf) cells (say), only one boolean each is set
// in it; the rest are all nulls. If the SP/TM rules have been
// applied, more than one boolean may be non-null in a cell query
for (int i = 0; i < bools1.Count; i++)
{
BoolExpression merged = null;
if (bools1[i] == null)
{
merged = bools2[i];
}
else if (bools2[i] == null)
{
merged = bools1[i];
}
else
{
if (opType == CellTreeOpType.IJ)
{
merged = BoolExpression.CreateAnd(bools1[i], bools2[i]);
}
else if (opType == CellTreeOpType.Union)
{
merged = BoolExpression.CreateOr(bools1[i], bools2[i]);
}
else if (opType == CellTreeOpType.LASJ)
{
merged = BoolExpression.CreateAnd(bools1[i],
BoolExpression.CreateNot(bools2[i]));
}
else
{
Debug.Fail("No other operation expected for boolean merge");
}
}
if (merged != null)
{
merged.ExpensiveSimplify();
}
bools.Add(merged);
}
return bools;
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:64,代码来源:CellTreeSimplifier.cs
示例19: AddWhenThen
/// <summary>
/// Adds an expression of the form "WHEN <paramref name="condition" /> THEN <paramref name="value" />".
/// This operation is not allowed after the <see cref="Simplify" /> call.
/// </summary>
internal void AddWhenThen(BoolExpression condition, ProjectedSlot value)
{
Debug.Assert(!m_simplified, "Attempt to modify a simplified case statement");
DebugCheck.NotNull(value);
condition.ExpensiveSimplify();
m_clauses.Add(new WhenThen(condition, value));
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:CaseStatement.cs
示例20: GetConjunctsFromWhereClause
private IEnumerable<MemberRestriction> GetConjunctsFromWhereClause(BoolExpression whereClause)
{
foreach (var boolExpr in whereClause.Atoms)
{
if (boolExpr.IsTrue)
{
continue;
}
var result = boolExpr.AsLiteral as MemberRestriction;
Debug.Assert(result != null, "Atom must be restriction");
yield return result;
}
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:13,代码来源:CellQuery.cs
注:本文中的BoolExpression类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论