asp.net mvc 5 - How to ignore properties marked with [IgnoreDataMember] when calling REST service -
i consuming rest xml service.
i have necessary classes this, (supplied dev wrote service) @ end have save of responses db perform tasks of app writing. have marked of these classes need put in db partial , extended them can inherit dbentity
class specifies id property can use ef save them db thus:
public interface idbentity { int id { get; set; } } [serializable] public class dbentity : idbentity { [ignoredatamember] [xmlignore] public int id { get; set; } }
the problem facing now, when service call being de-serialized error
error in line 1 position 113. 'element' 'elementname' namespace '' not expected. expecting element '_x003c_id_x003e_k__backingfield'
i making call this:
var response = await client.postasxmlasync<treq>("some/api/call", req); tresp val = await msg.content.readasasync<tresp>(response)
all properties in original classes have orders specified datamember
attributes , have marked db properties ignored, no avail.
is there way can work? - ie getting datacontractserializer
ignore properties have marked ignored when de-serializing?
as aside, these ignored properties being passed service when making call - ignoredatamember anything?
seems way this
public interface idbentity { int id { get; set; } } [serializable] [datacontract] public class dbentity : idbentity { [xmlignore] public int id { get; set; } }
so adding datacontract
attribute omitting datamember
attribute on item don't want
don't know how missed first time around. seems opt in rather opt out in instance.
Comments
Post a Comment