0

使用 devforce 7.2.2 我认为相关实体列表中有一个错误。

场景:我调用一个 RPC 方法来加载一个实体,包括其相关实体列表之一。我删除了子集合的一项,然后重新加载数据。使用默认的 QueryStrategy,我希望在相关实体列表中看不到已删除的实体。但它在那里并且处于已删除状态。

这种行为是预期的吗?

[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(); 
}
4

1 回答 1

0

鉴于您所展示的内容,我无法重现此行为;使用 Order 和 OrderDetail 实体类型以及 m:m 实体的简单测试工作正常。您是否还有其他未在此处显示的设置或代码?也许使用 EntityReferenceStrategy 或 MergeStrategy,或者在 RelatedEntityList 上调用 Reload?

于 2014-05-05T23:42:39.730 回答