在2sxc中,在App.Data.Create()之后,有没有办法获得新的实体ID(或Guid)或指向新实体的指针? [英] In 2sxc, after an App.Data.Create(), is there a way to get the new EntityId (or Guid) or a Pointer to the new Entity?
本文介绍了在2sxc中,在App.Data.Create()之后,有没有办法获得新的实体ID(或Guid)或指向新实体的指针?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
App.Data.Create()
以编程方式将新实体添加到Content-Type,然后需要将该新实体添加到我将要创建的下一个实体。Create(不同Content-Type中的新记录)。
由于.Create()不返回任何内容,访问新项目的最佳、正确或优雅的方式是什么?
这是我古怪的解决方案,但似乎还有一种更合理的方法。此外,在繁忙的站点上,如果几乎同时存在多个.Create(),则这可能不起作用。
// find the newest one with the highest EntityId
int maxEntityId = 0;
var tmp = AsList(App.Data["Markers"])
.OrderByDescending(m => m.EntityId)
.FirstOrDefault()
;
if(tmp != null){
maxEntityId = tmp.EntityId;
}
推荐答案
是的,有:)。
var x = App.Data.Create(...);
// X is now an a IEntity
var dynX = AsDynamic(x);
这篇关于在2sxc中,在App.Data.Create()之后,有没有办法获得新的实体ID(或Guid)或指向新实体的指针?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文