Ejemplo n.º 1
0
        public void ODataQuerySupportsCustomDateTimeOffsetFilter()
        {
            var param = new Param1
            {
                SubmitTime = DateTimeOffset.Parse("2016-03-28T08:15:00.0971693+00:00"),
                State = "Ended"

            };

            var filter = new List<string>();
            filter.Add(string.Format("submitTime lt datetimeoffset'{0}'", Uri.EscapeDataString(param.SubmitTime.Value.ToString("O"))));
            filter.Add(string.Format("state ne '{0}'", param.State));
            var filterString = string.Join(" and ", filter.ToArray());


            var query = new ODataQuery<Param1>
            {
                Filter = filterString
            };
            Assert.Equal("$filter=submitTime lt datetimeoffset'2016-03-28T08%3A15%3A00.0971693%2B00%3A00' and state ne 'Ended'", query.ToString());
        }
Ejemplo n.º 2
0
 public void EncodingTheParameters()
 {
     var param = new Param1
     {
         Foo = "Microsoft.Web/sites"
     };
     var result = FilterString.Generate<Param1>(p => p.Foo == param.Foo);
     Assert.Equal("foo eq 'Microsoft.Web%2Fsites'", result);
 }