示例#1
0
        public List<FBEntity> GetCompany(QueryExpression qe)
        {
            //string strType=qe.QueryType;
            //switch (strType)
            //{
            //    case "T_FB_SUBJECTDEPTMENT":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    case "T_FB_SUBJECTCOMPANY":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    case "T_FB_SUBJECTPOST":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    case "T_FB_SUBJECTCOMPANYSET":
            //        listC = InnerGetCompany(qe);
            //        break;
            //    default:
            //        break;
            //}
            List<VirtualCompany> listC = InnerGetCompany(qe);
            List<FBEntity> listResult = listC.ToFBEntityList();
            listResult.ForEach(company =>
            {
                VirtualCompany vcCompany = company.Entity as VirtualCompany;
                List<FBEntity> listDepartMent = vcCompany.DepartmentCollection.ToFBEntityList();
                RelationManyEntity rme = new RelationManyEntity();
                rme.EntityType = typeof(VirtualDepartment).Name;
                rme.FBEntities = listDepartMent;
                company.CollectionEntity.Add(rme);

                listDepartMent.ForEach(department =>
                {
                    VirtualDepartment virtualDepartment = department.Entity as VirtualDepartment;
                    List<FBEntity> listPost = virtualDepartment.PostCollection.ToFBEntityList();
                    RelationManyEntity rmePost = new RelationManyEntity();
                    rmePost.EntityType = typeof(VirtualPost).Name;
                    rmePost.FBEntities = listPost;
                    department.CollectionEntity.Add(rmePost);
                });
            });
            return listResult;
        }
示例#2
0
文件: FBEntityBLL.cs 项目: JuRogn/OA
        private void AttachRelationManyEntity(FBEntity entity, IRelatedEnd re)
        {
            Type t = re.GetType();
            Type eType = t.GetGenericArguments()[0];
            if (!re.IsLoaded) re.Load();             

            RelationManyEntity rManyE = new RelationManyEntity();
            rManyE.EntityType = eType.Name;
            rManyE.RelationshipName = re.RelationshipName;
            rManyE.PropertyName = re.TargetRoleName;
            entity.CollectionEntity.Add(rManyE);

            foreach (var item in re)
            {

                FBEntity tempEntity = new FBEntity();

                tempEntity.Entity = item as EntityObject;
                rManyE.FBEntities.Add(tempEntity);
            }
            //rManyE.FBEntities.ForEach(item =>
            //    {
            //        try
            //        {
            //            IEntityWithRelationships ie = item.Entity as IEntityWithRelationships;
            //            re.Remove(ie);
            //        }
            //        catch (Exception ex)
            //        {
            //        }
            //    });


        }