Exemplo n.º 1
0
 /// <summary>
 /// For now this only supports "and" query portions
 ///
 /// For filter string options / construction see: http://msdn.microsoft.com/en-us/library/azure/ff683669.aspx
 /// </summary>
 /// <param name="property"></param>
 /// <param name="op"></param>
 /// <param name="value"></param>
 public void AddFilter(string property, ODataOperator op, object value)
 {
     _filters.Add(new ODataFilter()
     {
         Property = property, Operator = op, Value = value
     });
 }
Exemplo n.º 2
0
        private void AppendFilterClause(string propertyName, object value, ODataOperator @operator, bool useOr)
        {
            var filterByProperty = $"extension_{_extensionApplicationId.Replace("-", string.Empty)}_{propertyName}";
            var valueString      = value is string
                                   ?$"'{value}'"
                                   : value is bool
                                   ?value.ToString().ToLower()
                                       : $"{value}";

            var operatorString = GetODataOperatorValue(@operator);
            var filterClause   = $"{filterByProperty} {operatorString} {valueString}";

            AppendFilterClause(filterClause, useOr);
        }
Exemplo n.º 3
0
        protected string GetODataOperatorValue(ODataOperator @operator)
        {
            switch (@operator)
            {
            case ODataOperator.Equals:
                return("eq");

            case ODataOperator.NotEquals:
                return("ne");

            case ODataOperator.LessThan:
                return("lt");

            case ODataOperator.GreaterThan:
                return("gt");

            case ODataOperator.LessThanEquals:
                return("le");

            case ODataOperator.GreaterThanEquals:
                return("ge");

            case ODataOperator.StartsWith:
                return("startswith");

            case ODataOperator.EndsWith:
                return("endswith");

            case ODataOperator.Null:
                return("eq null");

            case ODataOperator.NotNull:
                return("ne null");

            default:
                return(string.Empty);
            }
        }
Exemplo n.º 4
0
        public ODataQuery <TModel> Where <TItem, TProperty>(
            Expression <Func <TModel, IEnumerable <TItem> > > collectionExpression,
            Expression <Func <TItem, TProperty> > propertyExpression,
            TProperty value, ODataOperator @operator)
        {
            var filterByCollection = GetColumnName(collectionExpression.Body);
            var filterByProperty   = GetColumnName(propertyExpression.Body);
            var valueString        = value is string
                                     ?$"'{value}'"
                                     : value is bool
                                     ?value.ToString().ToLower()
                                         : $"{value}";

            var operatorString = GetODataOperatorValue(@operator);

            _filterClause = string.IsNullOrEmpty(_filterClause)
                ? string.Empty
                : _filterClause + " and ";

            _filterClause += $"{filterByCollection}/any(x: x/{filterByProperty} {operatorString} {valueString})";

            return(this);
        }
Exemplo n.º 5
0
        public static ODataQuery <User> WhereExtendedProperty(this ODataQuery <User> query, string propertyName, object value, ODataOperator @operator)
        {
            if (!(query is UserQuery))
            {
                throw new InvalidOperationException("Create a UserQuery instance via the GraphApiClient.UserQueryCreateAsync() in order to user Extended property filters.");
            }

            return(((UserQuery)query).WhereExtendedProperty(propertyName, value, @operator));
        }
Exemplo n.º 6
0
 public UserQuery OrWhereExtendedProperty(string propertyName, object value, ODataOperator @operator)
 {
     AppendFilterClause(propertyName, value, @operator, true);
     return(this);
 }
Exemplo n.º 7
0
        public ODataQuery <TModel> OrWhere <TProperty>(Expression <Func <TModel, TProperty> > propertyExpression, TProperty value, ODataOperator @operator)
        {
            var orderByProperty = GetColumnName(propertyExpression.Body);
            var valueString     = value is string
                                  ?$"'{value}'"
                                  : value is bool
                                  ?value.ToString().ToLower()
                                      : $"{value}";

            var operatorString = GetODataOperatorValue(@operator);

            _filterClause = string.IsNullOrEmpty(_filterClause)
                ? string.Empty
                : _filterClause + " or ";

            _filterClause += $"{orderByProperty} {operatorString} {value}";
            return(this);
        }
            /// <summary>
            /// Gets the tenant user count summaries asynchronously.
            /// </summary>
            /// <param name="dateFilter">The date filter.</param>
            /// <param name="operator">The operator.</param>
            /// <returns></returns>
            public async Task <IList <DailyTenantCountSummary> > GetTenantUserCountSummariesAsync(DateTimeOffset?dateFilter = null, ODataOperator @operator = ODataOperator.GreaterThan)
            {
                var resource = "reports/tenantUserCount";
                var query    = string.Empty;

                if (dateFilter.HasValue)
                {
                    query = new ODataQuery <DailyTenantCountSummary>()
                            .Where(x => x.TimeStamp, dateFilter.Value, @operator)
                            .ToString();
                }

                var result = await _client.ExecuteRequest <ODataResponse <DailyTenantCountSummary> >(HttpMethod.Get, resource, query, apiVersion : DefaultReportingApiVersion);

                return(result.Value);
            }
Exemplo n.º 9
0
 /// <summary>
 /// For now this only supports "and" query portions
 /// 
 /// For filter string options / construction see: http://msdn.microsoft.com/en-us/library/azure/ff683669.aspx
 /// </summary>
 /// <param name="property"></param>
 /// <param name="op"></param>
 /// <param name="value"></param>
 public void AddFilter(string property, ODataOperator op, object value)
 {
     _filters.Add(new ODataFilter() { Property = property, Operator = op, Value = value });
 }