c# - Automapper's ProjectTo throws serilization error -


i trying use automapper's projectto() extension method , running error:

the 'objectcontent`1' type failed serialize response body content type 'application/json; charset=utf-8'.

the inner exception is:

unable create null constant value of type 'datacontracts.statecontract'. entity types, enumeration types or primitive types supported in context.

call making looks this:

public iqueryable<origincontract> origins() {     return contextprovider.origins.projectto<origincontract>(automapperconfiguration); } 

and classes using this:

contracts:

public class origincontract {     public int originid { get; set; }     public string code { get; set; }     public string name { get; set; }     public string city { get; set; }     public int stateid { get; set; }     public statecontract state { get; set; } }  public class statecontract {     public int stateid { get; set; }     public string abbreviation { get; set; }     public string name { get; set; } } 

the entities have same properties , names (i copied , pasted 1 other.) can see them here if like.

one important note, if take out state property origin class, works fine. error has trying have origin class contains state class.

any ideas how past error?


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -