Exemple #1
0
        /// <summary>
        ///     Fetches all entities of the types specified from the database.
        /// </summary>
        /// <param name="entityType">
        ///     The entity type.
        /// </param>
        /// <param name="queryTypes">
        ///     The query types.
        /// </param>
        /// <param name="entitySink">
        ///     The entity sink, receives the entities fetched.
        /// </param>
        /// <param name="behaviors">
        ///     The behaviors.
        /// </param>
        public void Fetch(Type entityType, IEnumerable <Type> queryTypes, Action <object> entitySink, Behaviors behaviors)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException(nameof(entityType));
            }

            var entityReference = this.EntityReferenceForType(entityType);

            if (entityReference == null)
            {
                throw new PersistenceException(string.Format(CultureInfo.InvariantCulture, @"{0} is not a valid entity",
                                                             entityType));
            }

            EntityReader.Read(this, entityReference, this.ScanSpecForType(queryTypes), entitySink, behaviors);
        }
Exemple #2
0
        /// <summary>
        ///     Fetches all entities of the entity type specified from the database.
        /// </summary>
        /// <param name="entityType">
        ///     The entity type.
        /// </param>
        /// <param name="behaviors">
        ///     The behaviors.
        /// </param>
        /// <returns>
        ///     The entities fetched.
        /// </returns>
        public IEnumerable Fetch(Type entityType, Behaviors behaviors)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException(nameof(entityType));
            }

            var entityReference = this.EntityReferenceForType(entityType);

            if (entityReference == null)
            {
                throw new PersistenceException(string.Format(CultureInfo.InvariantCulture, @"{0} is not a valid entity",
                                                             entityType));
            }

            var scanSpec = this.ScanSpecForType(entityType);

            return(EntityReader.Read(this, entityReference, scanSpec, behaviors));
        }
Exemple #3
0
        /// <summary>
        ///     Find the entities in the database using the key providers specified.
        /// </summary>
        /// <param name="entityType">
        ///     The entity type.
        /// </param>
        /// <param name="keyProviders">
        ///     The key providers.
        /// </param>
        /// <param name="entitySink">
        ///     The entity sink, receives the entities fetched.
        /// </param>
        /// <param name="behaviors">
        ///     The behaviors.
        /// </param>
        public void FindMany(Type entityType, IEnumerable keyProviders, Action <object> entitySink, Behaviors behaviors)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException(nameof(entityType));
            }

            if (keyProviders == null)
            {
                throw new ArgumentNullException(nameof(keyProviders));
            }

            var entityReference = this.EntityReferenceForType(entityType);

            if (entityReference == null)
            {
                throw new PersistenceException(string.Format(CultureInfo.InvariantCulture, @"{0} is not a valid entity",
                                                             entityType));
            }

            EntityReader.Read(this, entityReference, keyProviders, entitySink, behaviors);
        }
Exemple #4
0
        /// <summary>
        ///     Find an entity in the database using the key provider specified.
        /// </summary>
        /// <param name="entityType">
        ///     The entity type.
        /// </param>
        /// <param name="keyProvider">
        ///     The key provider.
        /// </param>
        /// <param name="behaviors">
        ///     The behaviors.
        /// </param>
        /// <returns>
        ///     The found entity instance or null if the entity does not exist.
        /// </returns>
        public object Find(Type entityType, object keyProvider, Behaviors behaviors)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException(nameof(entityType));
            }

            if (keyProvider == null)
            {
                throw new ArgumentNullException(nameof(keyProvider));
            }

            var entityReference = this.EntityReferenceForType(entityType);

            if (entityReference == null)
            {
                throw new PersistenceException(string.Format(CultureInfo.InvariantCulture, @"{0} is not a valid entity",
                                                             entityType));
            }

            return(EntityReader.Read(this, entityReference, keyProvider, behaviors));
        }