使用 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();
}