Beispiel #1
0
        public void TestLinqToODataToODataExpressionLanguage()
        {
            var query = new A[0].AsQueryable()
                        .Select(a => new { x = a.B + 2 })
                        .OrderByDescending(t => t.x);

            var oData = LinqToOData.ToODataExpressionLanguage(query.Expression, new ODataQueryOptions());

            oData.ShouldEqual("?$orderby=B+add+2+desc&$format=json&$select=B");
        }
Beispiel #2
0
        public void TestLinqToODataTranslate()
        {
            var query = new A[0].AsQueryable()
                        .Where(a => a.B > 5)
                        .OrderBy(a => a.C);

            var translated = LinqToOData.Translate(query.Expression, new ODataQueryOptions());

            translated.ToString().ShouldEqual("?$filter=B+gt+5&$orderby=C&$format=json");
        }
Beispiel #3
0
        public void TestLinqToODataToNameValueCollection()
        {
            var query = new A[0].AsQueryable()
                        .Where(a => a.C.Length > 0)
                        .OrderBy(a => - 1 * a.B)
                        .Select(a => new { twice = a.C + a.C, @double = 2 * a.B });

            var collection = LinqToOData.ToNameValueCollection(query.Expression, new ODataQueryOptions(inlineCount: ODataInlineCountOption.AllPages));

            collection["$filter"].ShouldEqual("length(C) gt 0");
            collection["$orderby"].ShouldEqual("-1 mul B");
            collection["$select"].ShouldEqual("C,B");
            collection["$inlineCount"].ShouldEqual("allpages");
        }