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
Post a Comment