Esempio n. 1
0
        public bool FBEntityBllSave(FBEntity fbEntity)
        {
            try
            {
                // BeginTransaction();

                InnerSave(fbEntity);

                //  CommitTransaction();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            if (typeof(VirtualEntityObject).IsAssignableFrom(fbEntity.GetType()))
            {
                return(false);
            }
            //EntityObject newEntity = GetEntity(fbEntity.Entity.EntityKey);

            //FBEntity newFBEntity = new FBEntity();
            //newFBEntity.Entity = newEntity;
            //GetFBEntityFull(newFBEntity);
            //return newFBEntity;
            return(true);
        }
Esempio n. 2
0
        internal void InnerSave(FBEntity fbEntity)
        {
            List <FBEntity> listSave = new List <FBEntity>();

            if (fbEntity != null)
            {
                foreach (RelationManyEntity rEntity in fbEntity.CollectionEntity)
                {
                    rEntity.FBEntities.ForEach(subEntity =>
                    {
                        // 没改变的记录不修改
                        if (subEntity.FBEntityState == FBEntityState.Unchanged)
                        {
                            return;
                        }
                        RefreshData(subEntity.Entity);
                        listSave.Add(subEntity);
                    });
                }
                RefreshData(fbEntity.Entity);
                listSave.Add(fbEntity);
            }

            if ((fbEntity.FBEntityState == FBEntityState.Added) && (!typeof(VirtualEntityObject).IsAssignableFrom(fbEntity.GetType()))) // 添加的实体也一同把子实体也添加.
            {
                BassBllSave(fbEntity.Entity, fbEntity.FBEntityState);
            }
            else
            {
                listSave.ForEach(saveEntity =>
                {
                    BassBllSave(saveEntity.Entity, saveEntity.FBEntityState);
                });
            }
        }