Example #1
0
 public NavigationExpression(QueryNode input, PropertyExpression property, bool isLink)
     : base(input)
 {
     _isLink   = isLink;
     _property = property;
 }
Example #2
0
 //DML
 public static ProjectExpression Select(this QueryNode input, params ExpNode[] projection)
 {
     return(new ProjectExpression(input, projection));
 }
Example #3
0
 public NavigationExpression(QueryNode input, PropertyExpression property)
     : this(input, property, false)
 {
 }
Example #4
0
 public static OrderByExpression Sort(this QueryNode input, ExpNode[] properties, bool bAscDesc)
 {
     return(Sort(input, properties, bAscDesc, false));
 }
Example #5
0
 //Constructor
 public SingleExpression(QueryNode input, ResourceType resourceType)
     : base(input)
 {
     _resourceType = resourceType;
 }
Example #6
0
 //Constructor
 public CountExpression(QueryNode input, string countKind, QueryNode scannode)
     : base(input)
 {
     _countKind = countKind;
     _scannode  = scannode;
 }
Example #7
0
 public OrderByExpression(QueryNode input, ExpNode[] properties, QueryNode scannode, bool bAscDesc)
     : this(input, properties, scannode, bAscDesc, false)
 {
 }
Example #8
0
 public static PredicateExpression Where(this QueryNode input, ExpNode predicate)
 {
     return(new PredicateExpression(input, predicate));
 }
Example #9
0
 public static FirstOrDefaultExpression FirstOrDefault(this QueryNode input, ResourceType resourceType)
 {
     return(new FirstOrDefaultExpression(input, resourceType));
 }
Example #10
0
 public static QueryNode ExpandIfApplicable(this QueryNode input, PropertyExpression[] properties, bool applicable)
 {
     return(applicable ? Expand(input, properties) : input);
 }
Example #11
0
 public static OfTypeExpression OfType(this QueryNode input, ResourceType resourceType)
 {
     return(new OfTypeExpression(input, resourceType));
 }
Example #12
0
 public static QueryOptionExpression QueryOption(this QueryNode input, string optionName, string value)
 {
     return(new QueryOptionExpression(input, optionName, value));
 }
Example #13
0
 public static NavigationExpression Nav(this QueryNode input, PropertyExpression property, bool isLink)
 {
     return(new NavigationExpression(input, property, isLink));
 }
Example #14
0
 public static NewExpression New(this QueryNode input, params ExpNode[] members)
 {
     return(new NewExpression(input, members));
 }
Example #15
0
 public ExpandExpression(QueryNode input, PropertyExpression[] properties)
     : base(input)
 {
     _properties = properties;
 }
Example #16
0
 public static SingleOrDefaultExpression SingleOrDefault(this QueryNode input, ResourceType resourceType)
 {
     return(new SingleOrDefaultExpression(input, resourceType));
 }
Example #17
0
 public QueryOptionExpression(QueryNode input, string name, object value)
     : base(input)
 {
     _optionName = name;
     _value      = value;
 }
Example #18
0
 public static CountExpression Count(this QueryNode input, bool isInline)
 {
     return(Count(input, "allpages", isInline));
 }
Example #19
0
 //Constructor
 public SkipExpression(QueryNode input, int predicate, QueryNode scannode)
     : base(input)
 {
     _predicate = predicate;
     _scannode  = scannode;
 }
Example #20
0
        public static CountExpression Count(this QueryNode input, string countOption)
        {
            bool isInline = countOption.Contains("inline");

            return(Count(input, countOption, isInline));
        }
Example #21
0
 public ThenByExpression(QueryNode input, PropertyExpression[] properties, QueryNode scannode, bool bAscDesc)
     : this(input, properties, scannode, bAscDesc, false)
 {
 }
Example #22
0
 //Constructor
 public ProjectExpression(QueryNode input, params ExpNode[] projections)
     : base(input)
 {
     _projections = new Nodes <ExpNode>(this, projections);
 }
Example #23
0
 //Constructor
 public FirstOrDefaultExpression(QueryNode input, ResourceType resourceType)
     : base(input)
 {
     _resourceType = resourceType;
 }
Example #24
0
 //Constructor
 public PredicateExpression(QueryNode input, ExpNode predicate)
     : base(input)
 {
     _predicate = predicate;
     _type      = input.Type;
 }
Example #25
0
        private static bool compareKeyURI(string uriFound, KeyExpression keyExpected)
        {
            UriQueryBuilder builder = new UriQueryBuilder(keyExpected.ResourceContainer.Workspace, keyExpected.ResourceContainer.Workspace.ServiceUri);

            builder.EscapeUriValues          = true;
            builder.CleanUpSpecialCharacters = false;
            builder.UseBinaryFormatForDates  = false;

            switch (keyExpected.IncludeInUri.Count(i => i))
            {
            case 0:
                AstoriaTestLog.FailAndThrow("Cannot compare KeyExpression to URI, key has no included values");
                return(false);

            case 1:
                // TODO: stop ignoring case
                QueryNode query    = ContainmentUtil.BuildCanonicalQuery(keyExpected);
                string    expected = builder.Build(query);

                expected = expected.Replace(".0f", "f");     //this is kinda a hack, but TypeData.FormatForKey is going to add the .0, so we need to remove it
                expected = expected.Replace(".0D", "D");     //this is kinda a hack, but TypeData.FormatForKey is going to add the .0, so we need to remove it
                bool match = uriFound.Equals(expected, StringComparison.InvariantCultureIgnoreCase);
                if (!match)
                {
                    AstoriaTestLog.WriteLineIgnore("Link did not match key, expected '" + expected + "'");
                }
                return(match);

            default:
                QueryNode setQuery = ContainmentUtil.BuildCanonicalQuery(keyExpected, true);

                Workspace w      = keyExpected.ResourceContainer.Workspace;
                string    setUri = builder.Build(setQuery);

                string keySegment = uriFound.Substring(setUri.Length);

                string expectedKeySegment = "(" + UriQueryBuilder.CreateKeyString(keyExpected, false) + ")";

                if (keySegment.Equals(expectedKeySegment, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(true);
                }

                // if not explicitely equal, need to make sure its not due to a re-ordering of the properties
                //
                List <KeyValuePair <string, int> > predicateLocations = new List <KeyValuePair <string, int> >();
                for (int i = 0; i < keyExpected.Values.Length; i++)
                {
                    string predicate = builder.CreateKeyStringPair(keyExpected.Properties[i].Name, keyExpected.Values[i].ClrValue);
                    int    offset    = keySegment.IndexOf(predicate);
                    if (offset < 0)
                    {
                        return(false);
                    }

                    predicateLocations.Add(new KeyValuePair <string, int>(predicate, offset));
                }

                predicateLocations.Sort(delegate(KeyValuePair <string, int> pair1, KeyValuePair <string, int> pair2)
                {
                    return(pair1.Value.CompareTo(pair2.Value));
                });

                expectedKeySegment = "(" + String.Join(",", predicateLocations.Select(pair => pair.Key).ToArray()) + ")";

                return(keySegment.Equals(expectedKeySegment, StringComparison.InvariantCultureIgnoreCase));
            }
        }
Example #26
0
 public static ThenByExpression ThenBy(this QueryNode input, PropertyExpression[] properties, bool bAscDesc)
 {
     return(ThenBy(input, properties, bAscDesc, false));
 }