c# - Entity Framework query return my primary key plus $id -


this model class

public partial class tlog {     [key]     public int idlog { get; set; }     public string description { get; set; }     public system.datetime insertdate { get; set; } } 

and query method:

public static list<tlog> getalllogs()     {         var query = log in datacontext.log                         select log;         return query.tolist();     } 

the json returned is

[ {     "$id": "1",     "idlog": 1,     "description": "log1",     "insertdate": "2015-06-13t17:32:02.053" }, {     "$id": "2",     "idlog": 2,     "description": "log2",     "insertdate": "2015-06-13t17:52:39.637" } ] 

how can avoid $id in returned json have idlog?

use configure json serializer

var json = config.formatters.jsonformatter;         json.serializersettings.preservereferenceshandling =             newtonsoft.json.preservereferenceshandling.none; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -