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"); }
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"); }
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"); }