删除的实体查询后出现在relatedentitylist中
本文关键字:relatedentitylist 实体 查询 删除 | 更新日期: 2023-09-27 18:01:38
使用devforce 7.2.2时,我认为在relatedentitylist中有一个bug。
场景:我调用一个RPC方法,它加载一个实体,包括它的一个相关实体列表。删除子集合中的一个项,然后重新加载数据。使用默认的QueryStrategy,我希望在relatedentitylist中看不到被删除的实体。但它就在那里,并且处于已删除状态。
这个行为是预期的吗?
[AllowRpc]
public static void DoStuff(IPrincipal principal, EntityManager entityManager, params Object[] args)
{
var id = (int)args[0];
// Load of one EntityA and his RelatedEntityList of EntityB
var queryEntitiesA = new EntityQuery<EntityA>().With(entityManager).Include(EntityA.EntityPropertyNames.EntitiesB);
var entityA = queryEntitiesA.FirstOrDefault(m => m.Id == id);
// Count == 3
var count = entityA.EntitiesB.Count();
// Delete of one specific EntityB of the collection
var entityB = queryEntitiesA.EntitiesB.FirstOrDefault(md => md.Type == 1);
entityB.EntityFacts.Delete();
// Now Count == 2
count = entityA.EntitiesB.Count();
// Reexcution of the query with a new condition which include the EntityA previously loaded
var entities = queryEntitiesA.Where(p => "condition including the deleted entity").OrderBy(m => m.Date).Execute().ToList();
// Now the collection is back with a count of 3, including the deleted EntityB. The state of the entity is Deleted
count = entityA.EntitiesB.Count();
}
鉴于您所展示的,我无法复制此行为;使用Order和OrderDetail实体类型以及m:m实体的简单测试可以正常工作。您还有其他没有显示的设置或代码吗?也许与EntityReferenceStrategy或MergeStrategy,或在RelatedEntityList上调用Reload ?