【问题标题】:Deleted entity appears in relatedentitylist after querying查询后删除的实体出现在relatedentitylist中
【发布时间】:2014-05-05 11:16:20
【问题描述】:

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

【问题讨论】:

    标签: c# devforce


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2013-08-05
      • 2015-11-25
      • 1970-01-01
      • 1970-01-01
      • 2012-07-14
      • 1970-01-01
      • 1970-01-01
      • 2019-06-03
      • 1970-01-01
      相关资源
      最近更新 更多