public T[] LoadInternal <T>(string[] ids)
        {
            var loadOeration = new LoadOperation(this);

            loadOeration.ByIds(ids);

            var command = loadOeration.CreateRequest();

            if (command != null)
            {
                RequestExecuter.Execute(command, Context);
                loadOeration.SetResult(command.Result);
            }

            return(loadOeration.GetDocuments <T>());
        }
        public T[] LoadInternal <T>(string[] ids, KeyValuePair <string, Type>[] includes)
        {
            var loadOeration = new LoadOperation(this);

            loadOeration.ByIds(ids);
            loadOeration.WithIncludes(includes?.Select(x => x.Key).ToArray());

            var command = loadOeration.CreateRequest();

            if (command != null)
            {
                RequestExecuter.Execute(command, Context);
                loadOeration.SetResult(command.Result);
            }

            return(loadOeration.GetDocuments <T>());
        }
Exemple #3
0
        /// <inheritdoc />
        public async Task <T> LoadAsync <T>(string id, CancellationToken token = default(CancellationToken))
        {
            var loadOperation = new LoadOperation(this);

            loadOperation.ById(id);

            var command = loadOperation.CreateRequest();

            if (command != null)
            {
                await RequestExecutor.ExecuteAsync(command, Context, token, SessionInfo).ConfigureAwait(false);

                loadOperation.SetResult(command.Result);
            }

            return(loadOperation.GetDocument <T>());
        }
Exemple #4
0
        public Dictionary <string, T> LoadInternal <T>(string[] ids, string[] includes)
        {
            var loadOperation = new LoadOperation(this);

            loadOperation.ByIds(ids);
            loadOperation.WithIncludes(includes);

            var command = loadOperation.CreateRequest();

            if (command != null)
            {
                RequestExecutor.Execute(command, Context, sessionInfo: SessionInfo);
                loadOperation.SetResult(command.Result);
            }

            return(loadOperation.GetDocuments <T>());
        }
        public async Task <T[]> LoadAsync <T>(IEnumerable <string> ids,
                                              CancellationToken token = default(CancellationToken))
        {
            var loadOeration = new LoadOperation(this);

            loadOeration.ByIds(ids);

            var command = loadOeration.CreateRequest();

            if (command != null)
            {
                await RequestExecuter.ExecuteAsync(command, Context, token);

                loadOeration.SetResult(command.Result);
            }

            return(loadOeration.GetDocuments <T>());
        }
Exemple #6
0
        public async Task <Dictionary <string, T> > LoadAsyncInternal <T>(string[] ids, string[] includes,
                                                                          CancellationToken token = new CancellationToken())
        {
            var loadOperation = new LoadOperation(this);

            loadOperation.ByIds(ids);
            loadOperation.WithIncludes(includes?.ToArray());

            var command = loadOperation.CreateRequest();

            if (command != null)
            {
                await RequestExecutor.ExecuteAsync(command, Context, token, SessionInfo).ConfigureAwait(false);

                loadOperation.SetResult(command.Result);
            }

            return(loadOperation.GetDocuments <T>());
        }
Exemple #7
0
        private void LoadInternal(string[] ids, LoadOperation operation, Stream stream = null)
        {
            operation.ByIds(ids);

            var command = operation.CreateRequest();

            if (command != null)
            {
                RequestExecutor.Execute(command, Context, sessionInfo: SessionInfo);
                if (stream != null)
                {
                    Context.Write(stream, command.Result.Results.Parent);
                }
                else
                {
                    operation.SetResult(command.Result);
                }
            }
        }
        public async Task <T[]> LoadAsyncInternal <T>(string[] ids, KeyValuePair <string, Type>[] includes,
                                                      CancellationToken token = new CancellationToken())
        {
            var loadOeration = new LoadOperation(this);

            loadOeration.ByIds(ids);
            loadOeration.WithIncludes(includes?.Select(x => x.Key).ToArray());

            var command = loadOeration.CreateRequest();

            if (command != null)
            {
                await RequestExecuter.ExecuteAsync(command, Context, token);

                loadOeration.SetResult(command.Result);
            }

            return(loadOeration.GetDocuments <T>());
        }
        /// <summary>
        /// Loads the specified entity with the specified id.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public T Load <T>(string id)
        {
            if (id == null)
            {
                return(default(T));
            }
            var loadOeration = new LoadOperation(this);

            loadOeration.ById(id);

            var command = loadOeration.CreateRequest();

            if (command != null)
            {
                RequestExecuter.Execute(command, Context);
                loadOeration.SetResult(command.Result);
            }

            return(loadOeration.GetDocument <T>());
        }
Exemple #10
0
        private async Task LoadAsyncInternal(string[] ids, Stream stream, LoadOperation operation,
                                             CancellationToken token = default(CancellationToken))
        {
            operation.ByIds(ids);

            var command = operation.CreateRequest();

            if (command != null)
            {
                await RequestExecutor.ExecuteAsync(command, Context, token, SessionInfo).ConfigureAwait(false);

                if (stream != null)
                {
                    Context.Write(stream, command.Result.Results.Parent);
                }
                else
                {
                    operation.SetResult(command.Result);
                }
            }
        }