本文整理汇总了C#中IAsyncDocumentSession类的典型用法代码示例。如果您正苦于以下问题:C# IAsyncDocumentSession类的具体用法?C# IAsyncDocumentSession怎么用?C# IAsyncDocumentSession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IAsyncDocumentSession类属于命名空间,在下文中一共展示了IAsyncDocumentSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public IEnumerable<Task> Initialize(IAsyncDocumentSession session)
{
// those are no longer needed, when we request the
// Silverlight UI from the server, those indexes will
// be created automatically
//yield return session.Advanced.AsyncDatabaseCommands
// .PutIndexAsync<RavenDocumentsByEntityName>(true);
//yield return session.Advanced.AsyncDatabaseCommands
// .PutIndexAsync<RavenCollections>(true);
SimpleLogger.Start("preloading collection templates");
var templateProvider = IoC.Get<IDocumentTemplateProvider>();
var collections = session.Advanced.AsyncDatabaseCommands.GetCollectionsAsync(0, 25);
yield return collections;
var preloading = collections.Result
.Select(x=>x.Name)
.Union(Enumeration.All<BuiltinCollectionName>().Select(x => x.Value))
.Select(templateProvider.GetTemplateFor);
foreach (var task in preloading)
yield return task;
SimpleLogger.End("preloading collection templates");
}
示例2: FromDbFormat
internal static async Task<AuthorizationCode> FromDbFormat(StoredAuthorizationCode code, IAsyncDocumentSession s, IScopeStore scopeStore)
{
var result = new AuthorizationCode
{
CreationTime = code.CreationTime,
IsOpenId = code.IsOpenId,
RedirectUri = code.RedirectUri,
WasConsentShown = code.WasConsentShown,
Nonce = code.Nonce,
Client = Data.StoredClient.FromDbFormat(await s.LoadAsync<Data.StoredClient>("clients/" + code.Client)),
CodeChallenge = code.CodeChallenge,
CodeChallengeMethod = code.CodeChallengeMethod,
SessionId = code.SessionId,
RequestedScopes = await scopeStore.FindScopesAsync(code.RequestedScopes)
};
var claimsPrinciple = new ClaimsPrincipal();
foreach (var id in code.Subject)
{
claimsPrinciple.AddIdentity(Data.StoredIdentity.FromDbFormat(id));
}
result.Subject = claimsPrinciple;
return result;
}
示例3: DiscoveryModule
public DiscoveryModule(IAsyncDocumentSession session)
: base("/api/discovery")
{
this.session = session;
Get["/start"] = parameters =>
{
var discoveryClient = new ClusterDiscoveryClient(SenderId, "http://localhost:9020/api/discovery/notify");
discoveryClient.PublishMyPresenceAsync();
return "started";
};
Post["/notify", true] = async (parameters, ct) =>
{
var input = this.Bind<ServerRecord>("Id");
var server = await session.Query<ServerRecord>().Where(s => s.Url == input.Url).FirstOrDefaultAsync() ?? new ServerRecord();
this.BindTo(server, "Id");
await session.StoreAsync(server);
await HealthMonitorTask.FetchServerDatabases(server, session.Advanced.DocumentStore);
return "notified";
};
}
示例4: BlogPostController
public BlogPostController(IMvcLogger logger, IAsyncDocumentSession documentSession, IConfigurationManager configManager, AkismetClient akismetClient, IMappingEngine mapper)
: base(logger, documentSession)
{
_configManager = configManager;
_akismetClient = akismetClient;
_mapper = mapper;
}
示例5: AsyncQuery
public IQueryable<Record> AsyncQuery(IAsyncDocumentSession adb, RecordQueryInputModel input)
{
var query = adb.Query<RecordIndex.Result, RecordIndex>()
.Statistics(out stats);
return RecordQueryImpl(input, query);
}
示例6: CreateContextWithAsyncSessionPresent
public static ContextBag CreateContextWithAsyncSessionPresent(this RavenDBPersistenceTestBase testBase, out IAsyncDocumentSession session)
{
var context = new ContextBag();
session = testBase.OpenAsyncSession();
context.Set(session);
return context;
}
示例7: Initialize
public IEnumerable<Task> Initialize(IAsyncDocumentSession session)
{
yield return session.Advanced.AsyncDatabaseCommands
.PutIndexAsync(@"Studio/DocumentCollections",
new IndexDefinition
{
Map =
@"from doc in docs
let Name = doc[""@metadata""][""Raven-Entity-Name""]
where Name != null
select new { Name , Count = 1}
",
Reduce =
@"from result in results
group result by result.Name into g
select new { Name = g.Key, Count = g.Sum(x=>x.Count) }"
}, true);
// preload collection templates
var templateProvider = IoC.Get<IDocumentTemplateProvider>();
var collections = session.Advanced.AsyncDatabaseCommands.GetCollectionsAsync(0, 25);
yield return collections;
var preloading = collections.Result
.Select(x=>x.Name)
.Union(Enumeration.All<BuiltinCollectionName>().Select(x => x.Value))
.Select(templateProvider.GetTemplateFor);
foreach (var task in preloading)
yield return task;
}
示例8: CreateAsyncServerClient
public static async Task<AsyncServerClient> CreateAsyncServerClient(IAsyncDocumentSession session, ServerRecord server, ServerCredentials serverCredentials = null)
{
var documentStore = (DocumentStore)session.Advanced.DocumentStore;
var replicationInformer = new ReplicationInformer(new DocumentConvention
{
FailoverBehavior = FailoverBehavior.FailImmediately
});
ICredentials credentials = null;
if (serverCredentials != null)
{
credentials = serverCredentials.GetCredentials();
}
else if (server.CredentialsId != null)
{
serverCredentials = await session.LoadAsync<ServerCredentials>(server.CredentialsId);
if (serverCredentials == null)
{
server.CredentialsId = null;
}
else
{
credentials = serverCredentials.GetCredentials();
}
}
return new AsyncServerClient(server.Url, documentStore.Conventions, credentials,
documentStore.JsonRequestFactory, null, s => replicationInformer, null, new IDocumentConflictListener[0]);
}
示例9: SaveEntities
protected static async Task SaveEntities(IEnumerable<IEntity> entities, IAsyncDocumentSession session)
{
foreach (var entity in entities)
{
await session.StoreAsync(entity);
}
await session.SaveChangesAsync();
}
示例10: DoStuff
public async Task DoStuff(EndpointConfiguration configuration, IAsyncDocumentSession someAsyncSession)
{
#region 3to4-ravensharedsession
Func<IAsyncDocumentSession> sessionFactory = () => someAsyncSession;
configuration.UsePersistence<RavenDBPersistence>()
.UseSharedAsyncSession(sessionFactory);
#endregion
}
示例11: DoStuff
void DoStuff(EndpointConfiguration endpointConfiguration, IAsyncDocumentSession someAsyncSession)
{
#region 3to4-ravensharedsession
Func<IAsyncDocumentSession> sessionFactory = () => someAsyncSession;
var persistence = endpointConfiguration.UsePersistence<RavenDBPersistence>();
persistence.UseSharedAsyncSession(sessionFactory);
#endregion
}
示例12: EnsureSubscriptionsExists
private async Task EnsureSubscriptionsExists(IAsyncDocumentSession session)
{
var subscription = await session.LoadAsync<Subscription>(Subscription.Id);
if (subscription == null)
{
subscription = new Subscription();
await session.StoreAsync(subscription);
await session.SaveChangesAsync();
}
}
示例13: GetKnocksByFeedId
private async Task<IEnumerable<Knock>> GetKnocksByFeedId(IAsyncDocumentSession session, string feedId)
{
if (session == null)
throw new ArgumentNullException(nameof(session));
if (String.IsNullOrWhiteSpace(feedId))
throw new ArgumentNullException(nameof(feedId));
return await session.Query<Knock, Knock_ByFeed>().Where(knock => knock.FeedId==feedId).ToListAsync();
}
示例14: CreateCustomer
public static void CreateCustomer(IAsyncDocumentSession session, string name, AddressOptions addressOptions)
{
var entity = new Customer { Name = name };
if (addressOptions == AddressOptions.Home || addressOptions == AddressOptions.HomeAndBusines)
entity.Addresses.Add(CreateAddress(AddressOptions.Home));
if (addressOptions == AddressOptions.Business || addressOptions == AddressOptions.HomeAndBusines)
entity.Addresses.Add(CreateAddress(AddressOptions.Business));
session.Store(entity);
}
示例15: FirstQuery
static Task<IList<string>> FirstQuery(IAsyncDocumentSession session)
{
var now = DateTime.UtcNow;
RavenQueryStatistics stats;
return session.Query<Logfile>()
.Statistics(out stats)
.Where(x => x.UploadDate >= now.AddMonths(-1))
.Select(x => x.Owner)
.Distinct()
.Take(1024) // see
.ToListAsync();
}