Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 171 lines (151 sloc) 5.905 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
//-----------------------------------------------------------------------
// <copyright file="IAsyncDocumentSession.cs" company="Hibernating Rhinos LTD">
// Copyright (c) Hibernating Rhinos LTD. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using Raven.Client.Document;
using Raven.Client.Indexes;

namespace Raven.Client
{
using Linq;

/// <summary>
/// Interface for document session using async approaches
/// </summary>
public interface IAsyncDocumentSession : IDisposable
{
/// <summary>
/// Get the accessor for advanced operations
/// </summary>
/// <remarks>
/// Those operations are rarely needed, and have been moved to a separate
/// property to avoid cluttering the API
/// </remarks>
IAsyncAdvancedSessionOperations Advanced { get; }

/// <summary>
/// Begin a load while including the specified path
/// </summary>
/// <param name="path">The path.</param>
IAsyncLoaderWithInclude<object> Include(string path);

/// <summary>
/// Begin a load while including the specified path
/// </summary>
/// <param name="path">The path.</param>
IAsyncLoaderWithInclude<T> Include<T>(Expression<Func<T, object>> path);

/// <summary>
/// Begin a load while including the specified path
/// </summary>
/// <param name="path">The path.</param>
IAsyncLoaderWithInclude<T> Include<T, TInclude>(Expression<Func<T, object>> path);

/// <summary>
/// Stores the specified entity with the specified etag.
/// The entity will be saved when <see cref="SaveChangesAsync"/> is called.
/// </summary>
Task StoreAsync(object entity, Guid etag);

/// <summary>
/// Stores the specified entity in the session. The entity will be saved when <see cref="SaveChangesAsync"/> is called.
/// </summary>
/// <param name="entity">The entity.</param>
Task StoreAsync(object entity);

/// <summary>
/// Stores the specified entity with the specified etag, under the specified id
/// </summary>
Task StoreAsync(object entity, Guid etag, string id);

/// <summary>
/// Stores the specified dynamic entity, under the specified id
/// </summary>
/// <param name="entity">The entity.</param>
/// <param name="id">The id to store this entity under. If other entity exists with the same id it will be overridden.</param>
Task StoreAsync(object entity, string id);

/// <summary>
/// Marks the specified entity for deletion. The entity will be deleted when <see cref="SaveChangesAsync"/> is called.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="entity">The entity.</param>
void Delete<T>(T entity);

/// <summary>
/// Begins the async load operation
/// </summary>
/// <param name="id">The id.</param>
/// <returns></returns>
Task<T> LoadAsync<T>(string id);

/// <summary>
/// Begins the async multi-load operation
/// </summary>
/// <param name="ids">The ids.</param>
/// <returns></returns>
Task<T[]> LoadAsync<T>(params string[] ids);

/// <summary>
/// Begins the async multi-load operation
/// </summary>
/// <param name="ids">The ids.</param>
/// <returns></returns>
Task<T[]> LoadAsync<T>(IEnumerable<string> ids);

/// <summary>
/// Begins the async load operation, with the specified id after applying
/// conventions on the provided id to get the real document id.
/// </summary>
/// <remarks>
/// This method allows you to call:
/// LoadAsync{Post}(1)
/// And that call will internally be translated to
/// LoadAsync{Post}("posts/1");
///
/// Or whatever your conventions specify.
/// </remarks>
Task<T> LoadAsync<T>(ValueType id);

/// <summary>
/// Begins the async multi-load operation, with the specified ids after applying
/// conventions on the provided ids to get the real document ids.
/// </summary>
/// <remarks>
/// This method allows you to call:
/// LoadAsync{Post}(1,2,3)
/// And that call will internally be translated to
/// LoadAsync{Post}("posts/1","posts/2","posts/3");
///
/// Or whatever your conventions specify.
/// </remarks>
Task<T[]> LoadAsync<T>(params ValueType[] ids);

/// <summary>
/// Begins the async multi-load operation, with the specified ids after applying
/// conventions on the provided ids to get the real document ids.
/// </summary>
/// <remarks>
/// This method allows you to call:
/// LoadAsync{Post}(new List&lt;int&gt;(){1,2,3})
/// And that call will internally be translated to
/// LoadAsync{Post}("posts/1","posts/2","posts/3");
///
/// Or whatever your conventions specify.
/// </remarks>
Task<T[]> LoadAsync<T>(IEnumerable<ValueType> ids);

/// <summary>
/// Begins the async save changes operation
/// </summary>
/// <returns></returns>
Task SaveChangesAsync();

/// <summary>
/// Queries the specified index using Linq.
/// </summary>
/// <typeparam name="T">The result of the query</typeparam>
/// <param name="indexName">Name of the index.</param>
/// <param name="isMapReduce">Whatever we are querying a map/reduce index (modify how we treat identifier properties)</param>
IRavenQueryable<T> Query<T>(string indexName, bool isMapReduce = false);

/// <summary>
/// Dynamically queries RavenDB using LINQ
/// </summary>
/// <typeparam name="T">The result of the query</typeparam>
IRavenQueryable<T> Query<T>();

/// <summary>
/// Queries the index specified by <typeparamref name="TIndexCreator"/> using Linq.
/// </summary>
/// <typeparam name="T">The result of the query</typeparam>
/// <typeparam name="TIndexCreator">The type of the index creator.</typeparam>
/// <returns></returns>
IRavenQueryable<T> Query<T, TIndexCreator>() where TIndexCreator : AbstractIndexCreationTask, new();
}
}
Something went wrong with that request. Please try again.