示例#1
0
        public async Task FindAllByFilterWithDateTimeOffsetCastFromDateTimeOffset()
        {
            var created = new DateTimeOffset(2010, 12, 1, 12, 11, 10, TimeSpan.FromHours(0));
            var command = _client
                          .For <Order>()
                          .Filter(x => x.ShippedDateTimeOffset > (DateTimeOffset)created);
            var commandText = await command.GetCommandTextAsync();

            Assert.Equal($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}", commandText);
        }
示例#2
0
        public void FindAllByFilterWithDateTimeOffsetCastFromDateTime()
        {
            var created = new DateTime(2010, 12, 1, 12, 11, 10, DateTimeKind.Utc);
            var command = _client
                          .For <Order>()
                          .Filter(x => x.ShippedDateTimeOffset > (DateTimeOffset)created);
            var commandText = command.GetCommandTextAsync().Result;

            Assert.Equal($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}", commandText);
        }
    public async Task FindAllByFilterWithDateTimeOffsetCastFromDateTime()
    {
        var created = new DateTime(2010, 12, 1, 12, 11, 10, DateTimeKind.Utc);
        var command = _client
                      .For <Order>()
                      .Filter(x => x.ShippedDateTimeOffset > created);
        var commandText = await command.GetCommandTextAsync().ConfigureAwait(false);

        Assert.Equal($"Orders?$filter=ShippedDateTimeOffset%20gt%20{FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)}", commandText);
    }
        public void FindAllByFilterWithDateTimeOffset()
        {
            var created = new DateTimeOffset(2010, 12, 1, 12, 11, 10, TimeSpan.FromHours(0));
            var command = _client
                          .For <Order>()
                          .Filter(x => x.ShippedDateTimeOffset > created);
            string commandText = command.GetCommandTextAsync().Result;

            Assert.Equal(string.Format("Orders?$filter=ShippedDateTimeOffset%20gt%20{0}",
                                       FormatSettings.GetDateTimeOffsetFormat("2010-12-01T12:11:10Z", true)), commandText);
        }
    public void EqualDateTimeOffset()
    {
        Expression <Func <TestEntity, bool> > filter = x => x.Updated == new DateTimeOffset(new DateTime(2013, 1, 1, 0, 0, 0, DateTimeKind.Utc));

        Assert.Equal($"Updated eq {FormatSettings.GetDateTimeOffsetFormat("2013-01-01T00:00:00Z")}", ODataExpression.FromLinqExpression(filter).AsString(_session));
    }