asp.net - How to use JSON.NET to serialize an array of objects -


i remember 1 of friends told me can throw json.net , serialize them json format.

    public string getrecords(string apikey, datetime start, datetime end)     {         var user = db.users.singleordefault(u => u.id == apikey);          if (user == null)         {             return string.empty;         }          var records = db.histories.where(h => h.date >= start && h.date <= end);          javascriptserializer s = new javascriptserializer();          return jsonconvert.serializeobject(records);     } 

but got exception:

there open datareader associated command must closed first.

please help.

call .tolist() on records, before passing jsonconvert.serializeobject


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -