コード例 #1
0
        /// <summary>
        /// Creates and shows a document that contains a single object view model for the existing entity.
        /// Since CollectionViewModelBase is a POCO view model, an the instance of this class will also expose the EditCommand property that can be used as a binding source in views.
        /// </summary>
        /// <param name="projectionEntity">Entity to edit.</param>
        public virtual void Edit(TProjection projectionEntity)
        {
            if (Repository.IsDetached(projectionEntity))
            {
                return;
            }
            TPrimaryKey primaryKey = Repository.GetProjectionPrimaryKey(projectionEntity);
            int         index      = Entities.IndexOf(projectionEntity);

            projectionEntity = ChangeTrackerWithKey.FindActualProjectionByKey(primaryKey);
            if (index >= 0)
            {
                if (projectionEntity == null)
                {
                    Entities.RemoveAt(index);
                }
                else
                {
                    Entities[index] = projectionEntity;
                }
            }
            if (projectionEntity == null)
            {
                DestroyDocument(GetDocumentManagerService().FindEntityDocument <TEntity, TPrimaryKey>(primaryKey));
                return;
            }
            GetDocumentManagerService().ShowExistingEntityDocument <TEntity, TPrimaryKey>(this, primaryKey);
        }
コード例 #2
0
        void OnSelectEntityMessage(SelectEntityMessage message)
        {
            if (!IsLoaded)
            {
                return;
            }
            var projectionEntity = ChangeTrackerWithKey.FindActualProjectionByKey(message.PrimaryKey);

            if (projectionEntity == null)
            {
                FilterExpression = null;
                projectionEntity = ChangeTrackerWithKey.FindActualProjectionByKey(message.PrimaryKey);
            }
            SelectedEntity = projectionEntity;
        }
コード例 #3
0
        TProjection FindLocalProjectionWithSameKey(TProjection projectionEntity)
        {
            bool primaryKeyAvailable = projectionEntity != null && Repository.ProjectionHasPrimaryKey(projectionEntity);

            return(primaryKeyAvailable ? ChangeTrackerWithKey.FindLocalProjectionByKey(Repository.GetProjectionPrimaryKey(projectionEntity)) : null);
        }