コード例 #1
0
        public static void SetEntityKey(this IRelatedEnd relatedEnd, EntityKey key)
        {
            Debug.Assert(relatedEnd.IsEntityReference());
            Type         relationshipType = relatedEnd.GetType();
            PropertyInfo pi = relationshipType.GetProperty("EntityKey");

            pi.SetValue(relatedEnd, key, null);
        }
コード例 #2
0
        public static EntityKey GetEntityKey(this IRelatedEnd relatedEnd)
        {
            Debug.Assert(relatedEnd.IsEntityReference());
            Type         relationshipType = relatedEnd.GetType();
            PropertyInfo pi = relationshipType.GetProperty("EntityKey");

            return((EntityKey)pi.GetValue(relatedEnd, null));
        }
コード例 #3
0
    private static IEnumerable <TEntity> ExtractSingle <TEntity>(IRelatedEnd relatedEnd)
        where TEntity : class
    {
        var valueProp = relatedEnd.GetType().GetProperty("Value");
        var value     = valueProp?.GetValue(relatedEnd);

        yield return(value as TEntity);
    }
コード例 #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
        //
        // IRelatedEnd methods
        //

        public static bool IsEntityReference(this IRelatedEnd relatedEnd)
        {
            Type relationshipType = relatedEnd.GetType();

            return(relationshipType.GetGenericTypeDefinition() == typeof(EntityReference <>));
        }
コード例 #6
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)
            //        {
            //        }
            //    });


        }