コード例 #1
0
        /// <summary>
        ///     Gets the current instances.
        /// </summary>
        /// <returns>
        ///     An enumeration of the current entities.
        /// </returns>
        private IEnumerable <TEntity> GetCurrentInstances( )
        {
            return(_tracker.Select(pair =>
            {
                TEntity entity = null;

                if (!SourceIsReadOnly)
                {
                    // Get the entity as writeable
                    using (var ctx = new SourceEntityContext())
                    {
                        ctx.Writable = !SourceIsReadOnly;
                        entity = Entity.Get <TEntity>(pair.Key, SecurityOption.SkipDenied);
                    }
                }

                if (SourceIsReadOnly || entity == null)
                {
                    // The source is readonly or we don't have permission
                    // to get the entity as writeable.
                    entity = Entity.Get <TEntity>(pair.Key, SecurityOption.SkipDenied);
                }

                return entity;
            }));
        }
コード例 #2
0
        /// <summary>
        ///     Gets the current instances.
        /// </summary>
        /// <returns>
        ///     An enumeration of the current entities.
        /// </returns>
        private IEnumerable <TEntity> GetCurrentInstances( )
        {
            using (var ctx = new SourceEntityContext( ))
            {
                ctx.Writable = !SourceIsReadOnly;

                return(Entity.Get <TEntity>(_tracker.Select(pair => pair.Key)));
            }
        }