azure mobile services - What is a good way to insert an entity with dependencies using TableController? -
i struggling insert new entity references other existing entities using table controller in azure mobile services.
this set up:
entities:
public class entityb : entitydata { public entitya parent { get; set; } //some data } public class entitya : entitydata { //some data }
dtos:
public class dtoentityb : entitydata { public dtoentitya parent { get; set; } //some data } public class dtoentitya : entitydata { //some data }
controller:
public class controller : tablecontroller<dtoentityb> { public virtual async task<dtoentityb> post(dtoentityb entity) { return await insertasync(entity); } }
mapper:
automapper.mapper.initialize(cfg => { // use other mapper cfg.createmap<dtoentityb, entityb>(); cfg.createmap<entityb, dtoentityb>(); cfg.createmap<dtoentitya, entitya>(); cfg.createmap<entitya, dtoentitya>(); }
entitya exists already, make client call results in json sent post method. works fine until ef tells me there entitya id = 317238621736.
{ "entitya" : { "id" : "317238621736"} }
i looking generic solution problem (right direct operations on context (attach) every existing reference, combing mapper makes approach unsustainable.
Comments
Post a Comment