CodeFluent爱好者!
我的模型中有这两个相关的实体:
<cf:entity name="Main" defaultUsePersistenceDefaultValue="false" namespace="idscommerce" categoryPath="/idscommerce">
<cf:property name="Id" key="true" />
<cf:property name="Nom" />
<cf:property name="Ordre" />
<cf:property name="URL" />
<cf:property name="Icona" />
<cf:property name="Texts" typeName="{0}.MainTextCollection" relationPropertyName="Main" dataMember="true" />
<cf:entity name="MainText" defaultUsePersistenceDefaultValue="false" namespace="idscommerce" categoryPath="/idscommerce">
<cf:property name="Id" key="true" />
<cf:property name="Text" />
<cf:property name="Idioma" typeName="{0}.Idioma" relationPropertyName="MainTexts" />
<cf:property name="Main" typeName="{0}.Main" relationPropertyName="Texts" />
在我的API中,GET正常工作,但是当我发布POST(我正在使用[FromBody]主值选项)时,它会从MainTextCollection进入LoadByMain方法的循环。
// GET api/Main/id
public Main Get(string id)
{
idscommerce.Main value = idscommerce.Main.LoadByEntityKey(id);
if(value == null)
{
throw new HttpResponseException(HttpStatusCode.NotFound);
}
return value;
}
// POST api/Main
public HttpResponseMessage Post([FromBody]Main value)
{
if(value == null || !value.Save())
{
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
return Request.CreateResponse(HttpStatusCode.OK, value);
}
奇怪的是,当从Main.LoadAll()或Main.LoadById(id)调用时,同一个类按预期工作,但是当使用Post([FromBody]从API POST方法调用时,它会进入无限循环)主要价值)。