c# - IEnumerable of object returns JSON, but IEnumerable of similar object does not -


i have 2 classes similar. i'm trying see if can use one. first in our datamodel assembly, , used in our dbcontext.

public partial class type210_motorcarrierfreightinvoice {     public int motorcarrierfreightinvoiceid { get; set; } // motorcarrierfreightinvoiceid (primary key)     public string invoiceid { get; set; } // invoiceid     public datetime billdate { get; set; } // billdate      public string trackingnumber { get; set; } // trackingnumber      public decimal netshipmentcharge { get; set; } // netshipmentcharge      public long interchangetransactiondetailid { get; set; } // interchangetransactiondetailid      public long? billtoaddressid { get; set; } // billtoaddressid     public long? consigneeaddressid { get; set; } // consigneeaddressid     public long? shipperaddressid { get; set; } // shipperaddressid      // foreign keys     public virtual interchange_transactiondetail interchange_transactiondetail { get; set; } // fk_type210_motorcarrierfreightinvoice_interchange_transactiondetail     public virtual typeany_address typeany_address_billtoaddressid { get; set; }      public virtual typeany_address typeany_address_consigneeaddressid { get; set; }      public virtual typeany_address typeany_address_shipperaddressid { get; set; }       public type210_motorcarrierfreightinvoice()     {         initializepartial();     }      partial void initializepartial(); } 

the second class should represent same object.

public class type210motorcarrierfreightinvoice {     public int motorcarrierfreightinvoiceid { get; set; }     public string invoiceid { get; set; }     public datetime billdate { get; set; }      public string trackingnumber { get; set; }      public decimal netshipmentcharge { get; set; }     public long interchangetransactiondetailid { get; set; }     public address billtoaddress { get; set; }     public address consigneeaddress { get; set; }     public address shipperaddress { get; set; } } 

i'm working webapi service expose data via json. i'm trying this:

[route("api/subscriber/get210snew/{transactionid}")] [route("api/subscriber/get210snew/{transactionid}/{limit}")] public ienumerable<type210_motorcarrierfreightinvoice> get210sdoes_not_work(int transactionid, int limit = defaultlimit) {     var key = new queryafterid(transactionid, limit);     var dataservice = new type210dataservice(_edicontext);     return dataservice             .get(key)             .select(x => x); }  [route("api/subscriber/get210s/{transactionid}")] [route("api/subscriber/get210s/{transactionid}/{limit}")] public ienumerable<type210_motorcarrierfreightinvoice> get210sworks(int transactionid, int limit = defaultlimit) {     var key = new queryafterid(transactionid, limit);     var dataservice = new type210dataservice(_edicontext);     return dataservice             .get(key)             .select(map); } 

here map method:

private static type210motorcarrierfreightinvoice map(     type210_motorcarrierfreightinvoice dbnotice) {     return new type210motorcarrierfreightinvoice     {         motorcarrierfreightinvoiceid = dbnotice.motorcarrierfreightinvoiceid,         invoiceid = dbnotice.invoiceid,         billdate = dbnotice.billdate,         shipdate = dbnotice.shipdate,         trackingnumber = dbnotice.trackingnumber,         purchaseordernumber = dbnotice.purchaseordernumber,         billoflading = dbnotice.billoflading,         netshipmentcharge = dbnotice.netshipmentcharge,         interchangetransactiondetailid = dbnotice.interchangetransactiondetailid,         billtoaddress = mapper.maptoaddress(dbnotice.typeany_address_billtoaddressid),         consigneeaddress = mapper.maptoaddress(dbnotice.typeany_address_consigneeaddressid),         shipperaddress = mapper.maptoaddress(dbnotice.typeany_address_shipperaddressid)     }; } 

get210sworks return json data browser. get210sdoes_not_work not. both queries same number of records. get210sdoes_not_work shows no records in browser window.

why can't return ienumerable of datamodel class json?


Comments