Silverlight RIA Services随机填充实体

问题描述

| 我希望我在这里做错了。我正在NHibernate中使用RIA服务。 正在发生以下情况: 实体: 类别 int CategoryId 子类别 int SubCategoryId 类别父类别 int ParentCategoryId 在服务器端,我有一个查询获取所有子类别(假设本示例中有3个),NHibernate然后很好地播放并按预期填充Category属性,然后我在每个子类别上手动设置ParentCategoryId类别(这是为了使我与RIA服务正确关联),然后返回对象的IList。 现在,在客户端上,我可以按预期方式获得三个实体,但是ParentCategoryId属性ID仅填充了其中一个子类别?这怎么可能? 有任何想法吗? 服务器端代码
#DOMAIN SERVICE
    public IList<SubCategory> GetAllSubCategories()
    {
        var service = new Categoryapplicationservice();
        var subCats= service.GetAllSubCategories();

        return subCats;
    }

   #CATEGORY APPLICATION SERVICE
   public IList<SubCategory> GetAllSubCategories()
   {
      #some code to get the nhibernate session
           var repo = RepositoryFactory.GetRepository<ISubCategoryRepository,SubCategory>(session);
           var allCats = repo.FindAll();
           foreach (var s in allCats)
           {
               s.ParentCategoryId = s.ParentCategory.CategoryId;
           }

           return allCats;
       }
   }
    

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)