本文整理汇总了C#中IAsyncDocumentSession.Store方法的典型用法代码示例。如果您正苦于以下问题:C# IAsyncDocumentSession.Store方法的具体用法?C# IAsyncDocumentSession.Store怎么用?C# IAsyncDocumentSession.Store使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAsyncDocumentSession
的用法示例。
在下文中一共展示了IAsyncDocumentSession.Store方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: Index
public async Task<ActionResult> Index(IAsyncDocumentSession asyncSession)
{
// Remove when MVC 4 is released (http://forums.asp.net/p/1778103/4880898.aspx/1?Re+Using+an+Async+Action+to+Run+Synchronous+Code)
await Task.Yield();
var mike = (await asyncSession.Query<User>().Take(1).ToListAsync()).FirstOrDefault();
if (mike == null)
{
mike = new User {FirstName = "Mike", LastName = "Noonan"};
asyncSession.Store(mike);
await asyncSession.SaveChangesAsync();
}
if (mike.F1AccessToken == null || mike.PCOAccessToken == null)
{
return RedirectToAction("Authenticate", "F1Auth");
}
return View();
}
示例3: StoreVersioningData
private void StoreVersioningData(IEnumerable<VersioningConfiguration> versioningData, IAsyncDocumentSession session)
{
foreach (var data in versioningData)
{
if (data.Id.StartsWith("Raven/Versioning/", StringComparison.InvariantCultureIgnoreCase) == false)
data.Id = "Raven/Versioning/" + data.Id;
session.Store(data);
}
}
示例4: StoreAuthorizationData
private void StoreAuthorizationData(AuthorizationSettingsSectionModel authorizationSection, IAsyncDocumentSession session)
{
foreach (var authorizationRole in authorizationSection.AuthorizationRoles)
{
session.Store(authorizationRole);
}
foreach (var authorizationUser in authorizationSection.AuthorizationUsers)
{
session.Store(authorizationUser);
}
}
示例5: SaveApiKeys
private async Task SaveApiKeys(IAsyncDocumentSession session)
{
var apiKeysModel = settingsModel.Sections
.Where(sectionModel => sectionModel is ApiKeysSectionModel)
.Cast<ApiKeysSectionModel>()
.FirstOrDefault();
if (apiKeysModel == null)
return;
var apiKeysToDelete = apiKeysModel.OriginalApiKeys
.Where(apiKeyDefinition => apiKeysModel.ApiKeys.Contains(apiKeyDefinition) == false)
.ToList();
foreach (var apiKeyDefinition in apiKeysToDelete)
{
await ApplicationModel.DatabaseCommands.ForSystemDatabase().DeleteDocumentAsync(apiKeyDefinition.Id);
}
foreach (var apiKeyDefinition in apiKeysModel.ApiKeys)
{
apiKeyDefinition.Id = "Raven/ApiKeys/" + apiKeyDefinition.Name;
session.Store(apiKeyDefinition);
}
apiKeysModel.ApiKeys = new ObservableCollection<ApiKeyDefinition>(apiKeysModel.ApiKeys);
needToSaveChanges = true;
}
示例6: SaveWindowsAuth
private bool SaveWindowsAuth(IAsyncDocumentSession session)
{
var windowsAuthModel = settingsModel.Sections
.Where(sectionModel => sectionModel is WindowsAuthSettingsSectionModel)
.Cast<WindowsAuthSettingsSectionModel>()
.FirstOrDefault();
if (windowsAuthModel == null)
return false;
if (windowsAuthModel.RequiredGroups.Any(data => data.Name == null) ||
windowsAuthModel.RequiredGroups.Any(data => data.Name.Contains("\\") == false) ||
windowsAuthModel.RequiredUsers.Any(data => data.Name == null) ||
windowsAuthModel.RequiredUsers.Any(data => data.Name.Contains("\\") == false))
{
ApplicationModel.Current.Notifications.Add(
new Notification("Windows Authentication not saved!. All names must have \"\\\" in them", NotificationLevel.Error));
return false;
}
windowsAuthModel.Document.Value.RequiredGroups = windowsAuthModel.RequiredGroups.ToList();
windowsAuthModel.Document.Value.RequiredUsers = windowsAuthModel.RequiredUsers.ToList();
session.Store(RavenJObject.FromObject(windowsAuthModel.Document.Value), "Raven/Authorization/WindowsSettings");
needToSaveChanges = true;
return true;
}
示例7: SavePeriodicBackup
private async Task SavePeriodicBackup(PeriodicBackupSettingsSectionModel periodicBackup, IAsyncDocumentSession session)
{
if(periodicBackup.PeriodicBackupSetup == null)
return;
switch (periodicBackup.SelectedOption.Value)
{
case 0:
periodicBackup.PeriodicBackupSetup.GlacierVaultName = null;
periodicBackup.PeriodicBackupSetup.S3BucketName = null;
periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null;
break;
case 1:
periodicBackup.PeriodicBackupSetup.LocalFolderName = null;
periodicBackup.PeriodicBackupSetup.S3BucketName = null;
periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null;
break;
case 2:
periodicBackup.PeriodicBackupSetup.GlacierVaultName = null;
periodicBackup.PeriodicBackupSetup.LocalFolderName = null;
periodicBackup.PeriodicBackupSetup.AzureStorageContainer = null;
break;
case 3:
periodicBackup.PeriodicBackupSetup.GlacierVaultName = null;
periodicBackup.PeriodicBackupSetup.S3BucketName = null;
periodicBackup.PeriodicBackupSetup.LocalFolderName = null;
break;
}
settingsModel.DatabaseDocument.SecuredSettings["Raven/AWSSecretKey"] = periodicBackup.AwsSecretKey;
settingsModel.DatabaseDocument.Settings["Raven/AWSAccessKey"] = periodicBackup.AwsAccessKey;
settingsModel.DatabaseDocument.SecuredSettings["Raven/AzureStorageKey"] = periodicBackup.AzureStorageKey;
settingsModel.DatabaseDocument.Settings["Raven/AzureStorageAccount"] = periodicBackup.AzureStorageAccount;
string activeBundles;
settingsModel.DatabaseDocument.Settings.TryGetValue("Raven/ActiveBundles", out activeBundles);
if (activeBundles == null || activeBundles.Contains("PeriodicBackup") == false)
{
activeBundles = "PeriodicBackup;" + activeBundles;
}
settingsModel.DatabaseDocument.Settings["Raven/ActiveBundles"] = activeBundles;
await DatabaseCommands.CreateDatabaseAsync(settingsModel.DatabaseDocument);
session.Store(periodicBackup.PeriodicBackupSetup, PeriodicBackupSetup.RavenDocumentKey);
needToSaveChanges = true;
}
示例8: Save
public void Save(IAsyncDocumentSession session, Action<object> callback)
{
session.Store(jsonDocument);
session.SaveChangesAsync();
Id = jsonDocument.Key;
}
示例9: CreateProduct
public static void CreateProduct(IAsyncDocumentSession session, string name, decimal price)
{
var entity = new Product { Name = name, Price = price };
session.Store(entity);
}