Пример #1
0
        public async Task LoadByIdAsync(IQuerySession session, CancellationToken token = default(CancellationToken))
        {
            var userId = Guid.NewGuid();

            // Load a single document identified by a Guid
            var user = await session.LoadAsync <User>(userId, token);

            // There's an overload of Load for integers and longs
            var doc = await session.LoadAsync <IntDoc>(15, token);

            // Another overload for documents identified by strings
            var doc2 = await session.LoadAsync <StringDoc>("Hank", token);

            // Load multiple documents by a group of ids
            var users = await session.LoadManyAsync <User>(token, Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid());

            var ids = new Guid[] { Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid() };

            // If you already have an array of id values
            var users2 = await session.LoadManyAsync <User>(token, ids);
        }
Пример #2
0
 public async Task <IReadOnlyList <T> > LoadManyAsync <T>(params string[] ids)
 {
     return((await _querySession.LoadManyAsync <T>(ids).ConfigureAwait(false))
            .OnlyItemsTheUserCanSee(_securityQueryProvider, _martenContext)
            .ToList());
 }