how to return generic list of object in json result RRS feed

  • Question

  • User1720628292 posted

    In document db i have one collection called item ,the collection contains 2 documents .i want to show the 2 document data  (SELECT * FROM C")  and return it in json format.

    I can fetch the collection data but when i tried to show it returns the empty array.

     string authKey = ConfigurationManager.AppSettings["authKey"];
                var client = new DocumentClient(new Uri(endpoint),authKey);
                var db = (await client.ReadDatabaseFeedAsync()).Single(d => d.Id =="ToDoList");
                   var col = (await client.ReadDocumentCollectionFeedAsync(db.CollectionsLink)).Single(c => c.Id== "Items");
                var query = new SqlQuerySpec("SELECT * FROM Items c");
                dynamic document = client.CreateDocumentQuery<dynamic>(col.DocumentsLink, query).AsEnumerable().ToList();
    return Json(document, JsonRequestBehavior.AllowGet);

    Tuesday, May 30, 2017 7:27 AM