예제 #1
0
        /// <summary>
        /// Execute stored procedure in this collection
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="procId"></param>
        /// <param name="partitionKey"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public async Task <TResult> ExecuteStoredProcedureAsync <TResult>(string procId, object partitionKey, object args)
        {
            var url = UriFactory.CreateStoredProcedureUri(_settings.DatabaseId, _settings.CollectionId, procId);

            RequestOptions options = new RequestOptions()
            {
                PartitionKey = new PartitionKey(partitionKey)
            };

            return(await DocumentDbClient.ExecuteStoredProcedureAsync <TResult>(url, options, args));
        }
예제 #2
0
        public async Task <T> ExecuteStoredProcedure <T>(string storedProcedureName, params dynamic[] parameters)
        {
            var storedProc = DocumentDbClient.CreateStoredProcedureQuery(CollectionUri).Where(p => p.Id == storedProcedureName).AsEnumerable().FirstOrDefault();

            if (storedProc == null)
            {
                throw new ArgumentNullException($"Stored Procedure {storedProcedureName} does not exists on the database");
            }

            StoredProcedureResponse <T> response = null;

            response = await DocumentDbClient.ExecuteStoredProcedureAsync <T>(storedProc.SelfLink, parameters);

            return(response);
        }
예제 #3
0
        /// <summary>
        /// Execute stored procedure in this collection
        /// </summary>
        /// <typeparam name="TResult"></typeparam>
        /// <param name="procId"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public async Task <TResult> ExecuteStoredProcedureAsync <TResult>(string procId, object args)
        {
            var url = UriFactory.CreateStoredProcedureUri(_settings.DatabaseId, _settings.CollectionId, procId);

            return(await DocumentDbClient.ExecuteStoredProcedureAsync <TResult>(url, args));
        }