private void ExpandProperty(PropertyInfo p)
        {
            if (p.PropertyType.IsValueType || p.PropertyType == typeof(string))
            {
                return;
            }

            string name = p.Name + "Reference";

            PropertyInfo px = p.DeclaringType.GetProperty(name);

            if (px == null)
            {
                return;
            }

            ExpressionResult currentItem = ExpressionStack.Pop();

            IRelatedEnd end = px.GetValue(currentItem.Result, null) as IRelatedEnd;

            end.Load();

            object propertyValue = p.GetValue(currentItem.Result, null);

            if (ExpressionStack.Count > 0)
            {
                ExpressionStack.Peek().Result = propertyValue;
            }
        }
예제 #2
0
 private static IEnumerable <TEntity> ExtractValues <TEntity>(IRelatedEnd relatedEnd)
     where TEntity : class
 {
     if (!relatedEnd.IsLoaded)
     {
         relatedEnd.Load();
     }
     if (relatedEnd is IEnumerable enumerable)
     {
         return(ExtractCollection <TEntity>(enumerable));
     }
     else
     {
         return(ExtractSingle <TEntity>(relatedEnd));
     }
 }
예제 #3
0
파일: FBEntityBLL.cs 프로젝트: jjg0519/OA
 private void AttachRelationOneEntity(FBEntity entity, IRelatedEnd re)
 {
     //Type t = re.GetType();
     //Type eType = t.GetGenericArguments()[0];
     if (re.IsLoaded)
     {
         return;
     }
     re.Load();
     //RelationOneEntity rOneE = new RelationOneEntity();
     //rOneE.EntityType= eType.Name;
     //rOneE.RelationshipName = re.RelationshipName;
     //rOneE.PropertyName = re.TargetRoleName;
     //entity.ReferencedEntity.Add(rOneE);
     //foreach (var item in re)
     //{
     //    FBEntity tempEntity = new FBEntity();
     //    tempEntity.Entity = item as EntityObject;
     //    rOneE.FBEntity = tempEntity;
     //    // re.Remove(item as IEntityWithRelationships);
     //}
 }
예제 #4
0
파일: FBEntityBLL.cs 프로젝트: jjg0519/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)
            //        {
            //        }
            //    });
        }
예제 #5
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)
            //        {
            //        }
            //    });


        }
예제 #6
0
파일: FBEntityBLL.cs 프로젝트: JuRogn/OA
 private void AttachRelationOneEntity(FBEntity entity, IRelatedEnd re)
 {
     //Type t = re.GetType();
     //Type eType = t.GetGenericArguments()[0];
     if (re.IsLoaded) return;
     re.Load();
     //RelationOneEntity rOneE = new RelationOneEntity();
     //rOneE.EntityType= eType.Name;
     //rOneE.RelationshipName = re.RelationshipName;
     //rOneE.PropertyName = re.TargetRoleName;
     //entity.ReferencedEntity.Add(rOneE);
     //foreach (var item in re)
     //{
     //    FBEntity tempEntity = new FBEntity();
     //    tempEntity.Entity = item as EntityObject;
     //    rOneE.FBEntity = tempEntity;
     //    // re.Remove(item as IEntityWithRelationships);
     //}
 }
예제 #7
0
        /// <summary>
        ///     Calls Load on the underlying <see cref="IRelatedEnd" />.
        /// </summary>
        public virtual void Load()
        {
            ValidateNotDetached("Load");

            _relatedEnd.Load();
        }