本文整理汇总了C#中Microsoft.Azure.Documents.Client.DocumentClient类的典型用法代码示例。如果您正苦于以下问题:C# DocumentClient类的具体用法?C# DocumentClient怎么用?C# DocumentClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentClient类属于Microsoft.Azure.Documents.Client命名空间,在下文中一共展示了DocumentClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GetDocumentClient
public DocumentClient GetDocumentClient()
{
if (_documentClient != null) return _documentClient;
_documentClient = new DocumentClient(new Uri(_endpointUrl), _authorizationKey);
_documentClient.OpenAsync().Wait();
return _documentClient;
}
开发者ID:tzkwizard,项目名称:Azure,代码行数:7,代码来源:DBoperation.cs
示例2: InitializeHashResolver
/// <summary>
/// Initialize a HashPartitionResolver.
/// </summary>
/// <param name="partitionKeyPropertyName">The property name to be used as the partition Key.</param>
/// <param name="client">The DocumentDB client instance to use.</param>
/// <param name="database">The database to run the samples on.</param>
/// <param name="collectionNames">The names of collections used.</param>
/// <returns>The created HashPartitionResolver.</returns>
public static async Task<HashPartitionResolver> InitializeHashResolver(string partitionKeyPropertyName, DocumentClient client, Database database, string[] collectionNames)
{
// Set local to input.
string[] CollectionNames = collectionNames;
int numCollectionNames = CollectionNames.Length;
// Create array of DocumentCollections.
DocumentCollection[] collections = new DocumentCollection[numCollectionNames];
// Create string array of Self Links to Collections.
string[] selfLinks = new string[numCollectionNames];
//Create some collections to partition data.
for (int i = 0; i < numCollectionNames; i++)
{
collections[i] = await DocumentClientHelper.GetCollectionAsync(client, database, CollectionNames[i]);
selfLinks[i] = collections[i].SelfLink;
}
// Join Self Link Array into a comma separated string.
string selfLinkString = String.Join(", ", selfLinks);
//Initialize a partition resolver that users hashing, and register with DocumentClient.
//Uses User Id for PartitionKeyPropertyName, could also be TenantId, or any other variable.
HashPartitionResolver hashResolver = new HashPartitionResolver(partitionKeyPropertyName, new[] { selfLinkString });
client.PartitionResolvers[database.SelfLink] = hashResolver;
return hashResolver;
}
开发者ID:TheDarkCode,项目名称:AngularAzureSearch,代码行数:37,代码来源:PartitionInitializers.cs
示例3: DatabaseNode
public DatabaseNode(DocumentClient localclient, Database db)
{
Text = db.Id;
Tag = db;
_client = localclient;
ImageKey = "SystemFeed";
SelectedImageKey = "SystemFeed";
Nodes.Add(new UsersNode(_client));
MenuItem myMenuItem3 = new MenuItem("Read Database");
myMenuItem3.Click += new EventHandler(myMenuItemReadDatabase_Click);
_contextMenu.MenuItems.Add(myMenuItem3);
MenuItem myMenuItem = new MenuItem("Delete Database");
myMenuItem.Click += new EventHandler(myMenuItemDeleteDatabase_Click);
_contextMenu.MenuItems.Add(myMenuItem);
_contextMenu.MenuItems.Add("-");
MenuItem myMenuItem2 = new MenuItem("Create DocumentCollection");
myMenuItem2.Click += new EventHandler(myMenuItemAddDocumentCollection_Click);
_contextMenu.MenuItems.Add(myMenuItem2);
MenuItem myMenuItem4 = new MenuItem("Refresh DocumentCollections Feed");
myMenuItem4.Click += new EventHandler((sender, e) => Refresh(true));
_contextMenu.MenuItems.Add(myMenuItem4);
}
开发者ID:wmioduszewski,项目名称:DocumentDBStudio,代码行数:27,代码来源:DatabaseNode.cs
示例4: AzureDocumentDBSink
public AzureDocumentDBSink(Uri endpointUri, string authorizationKey, string databaseName, string collectionName, IFormatProvider formatProvider)
{
_formatProvider = formatProvider;
_client = new DocumentClient(endpointUri, authorizationKey);
Task.WaitAll(new []{CreateDatabaseIfNotExistsAsync(databaseName)});
Task.WaitAll(new []{CreateCollectionIfNotExistsAsync(collectionName)});
}
开发者ID:merbla,项目名称:serilog-sinks-azuredocumentdb,代码行数:7,代码来源:AzureDocumentDbSink.cs
示例5: Main
public static void Main(string[] args)
{
try
{
//Instantiate a new DocumentClient instance
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey, connectionPolicy))
{
//Get, or Create, a reference to Database
database = GetOrCreateDatabaseAsync(databaseId).Result;
//Do operations on Collections
RunCollectionDemo().Wait();
}
}
catch (DocumentClientException de)
{
Exception baseException = de.GetBaseException();
Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
}
catch (Exception e)
{
Exception baseException = e.GetBaseException();
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
}
finally
{
Console.WriteLine("End of demo, press any key to exit.");
Console.ReadKey();
}
}
开发者ID:svoss,项目名称:azure-documentdb-net,代码行数:30,代码来源:Program.cs
示例6: CreateDocumentCollection
private static void CreateDocumentCollection(DocumentClient documentClient)
{
// Create the database if it doesn't exist.
try
{
documentClient.ReadDocumentCollectionAsync(UriFactory.CreateDocumentCollectionUri(DatabaseName, CollectionName))
.GetAwaiter()
.GetResult();
}
catch (DocumentClientException de)
{
// If the document collection does not exist, create it
if (de.StatusCode == HttpStatusCode.NotFound)
{
var collectionInfo = new DocumentCollection
{
Id = CollectionName,
IndexingPolicy = new IndexingPolicy(new RangeIndex(DataType.String) { Precision = -1 })
};
documentClient.CreateDocumentCollectionAsync(
UriFactory.CreateDatabaseUri(DatabaseName),
collectionInfo,
new RequestOptions { OfferThroughput = 400 }).GetAwaiter().GetResult();
}
else
{
throw;
}
}
}
开发者ID:XpiritBV,项目名称:mini-hacks,代码行数:32,代码来源:Program.cs
示例7: Main
public static void Main(string[] args)
{
try
{
//Get a single instance of Document client and reuse this for all the samples
//This is the recommended approach for DocumentClient as opposed to new'ing up new instances each time
using (client = new DocumentClient(new Uri(endpointUrl), authorizationKey))
{
//ensure the database & collection exist before running samples
Init();
RunDocumentsDemo().Wait();
//Clean-up environment
Cleanup();
}
}
catch (DocumentClientException de)
{
Exception baseException = de.GetBaseException();
Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
}
catch (Exception e)
{
Exception baseException = e.GetBaseException();
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
}
finally
{
Console.WriteLine("\nEnd of demo, press any key to exit.");
Console.ReadKey();
}
}
开发者ID:taolin123,项目名称:azure-documentdb-dotnet,代码行数:33,代码来源:Program.cs
示例8: DatabaseAccountNode
public DatabaseAccountNode(string endpointName, DocumentClient client)
{
this.accountEndpoint = endpointName;
this.Text = endpointName;
if (string.Compare(endpointName, Constants.LocalEmulatorEndpoint, true) == 0)
{
this.Text = "devEmulator";
}
this.ImageKey = "DatabaseAccount";
this.SelectedImageKey = "DatabaseAccount";
this.client = client;
this.Tag = "This represents the DatabaseAccount. Right click to add Database";
this.loadindNode = new TreeNode(TreeNodeConstants.LoadingNode);
this.Nodes.Add(this.loadindNode);
MenuItem myMenuItem = new MenuItem("Add Database");
myMenuItem.Click += new EventHandler(myMenuItemAddDatabase_Click);
this.contextMenu.MenuItems.Add(myMenuItem);
MenuItem myMenuItem1 = new MenuItem("Refresh Databases feed");
myMenuItem1.Click += new EventHandler((sender, e) => Refresh(true));
this.contextMenu.MenuItems.Add(myMenuItem1);
this.contextMenu.MenuItems.Add("-");
MenuItem myMenuItem2 = new MenuItem("Remove setting");
myMenuItem2.Click += new EventHandler(myMenuItemRemoveDatabaseAccount_Click);
this.contextMenu.MenuItems.Add(myMenuItem2);
MenuItem myMenuItem3 = new MenuItem("Change setting");
myMenuItem3.Click += new EventHandler(myMenuItemChangeSetting_Click);
this.contextMenu.MenuItems.Add(myMenuItem3);
}
开发者ID:nomiero,项目名称:DocumentDBStudio,代码行数:35,代码来源:TreeNodes.cs
示例9: FindDocumentCollection
static DocumentCollection FindDocumentCollection(DocumentClient client, Database database, string name)
{
return client.CreateDocumentCollectionQuery(database.SelfLink)
.Where(x => x.Id == name)
.ToList()
.SingleOrDefault();
}
开发者ID:korz,项目名称:IntroductionToDocumentDB,代码行数:7,代码来源:Program.cs
示例10: UpdateDcAll
public static async Task UpdateDcAll(string endpointUrl, string authorizationKey)
{
DocumentClient client = new DocumentClient(new Uri(endpointUrl), authorizationKey);
var database = await DocumentDB.GetDB(client);
IEnumerable<DocumentCollection> dz = client.CreateDocumentCollectionQuery(database.SelfLink)
.AsEnumerable();
DocumentCollection origin = client.CreateDocumentCollectionQuery(database.SelfLink)
.Where(c => c.Id == "LMSCollection")
.AsEnumerable()
.FirstOrDefault();
//search collection
var ds =
from d in client.CreateDocumentQuery<DcAllocate>(origin.DocumentsLink)
where d.Type == "DisList"
select d;
foreach (var d in ds)
{
if (d.District.Contains("tst-azhang14"))
{
Console.WriteLine(d.DcName);
}
}
/* foreach (var x in dz)
{
Console.WriteLine(x.Id + x.DocumentsLink);
await UpdateDc(x, client, database, origin);
}*/
}
开发者ID:tzkwizard,项目名称:ELS,代码行数:33,代码来源:Dichotomy.cs
示例11: InitClient
void InitClient()
{
var endpoint = new Uri(this.Config["DocDb:endpoint"]);
var authKey = this.Config["DocDb:authkey"];
var connectionPolicy = GetConnectionPolicy();
Client = new DocumentClient(endpoint, authKey, connectionPolicy);
}
开发者ID:hpatel98,项目名称:SCAMP,代码行数:7,代码来源:DocDb.cs
示例12: FindDatabase
static Database FindDatabase(DocumentClient client, string name)
{
return client.CreateDatabaseQuery()
.Where(x => x.Id == name)
.ToList()
.SingleOrDefault();
}
开发者ID:korz,项目名称:IntroductionToDocumentDB,代码行数:7,代码来源:Program.cs
示例13: GetStartedDemo
public async Task GetStartedDemo()
{
try
{
var items = DataHelper.GetRealEstateT(int.Parse(DateTime.UtcNow.ToString("yyyyMMdd"))).Select(x => JsonHelper.Deserialize<RealEstateObj>(x.Data));
this.client = new DocumentClient(new Uri(EndpointUri), PrimaryKey);
await this.CreateDatabaseIfNotExists("fresdb");
await this.CreateDocumentCollectionIfNotExists("fresdb", "frescollection");
foreach (var item in items)
{
await this.CreateRealEstate("fresdb", "frescollection", item);
}
}
catch (DocumentClientException de)
{
Exception baseException = de.GetBaseException();
Console.WriteLine("{0} error occurred: {1}, Message: {2}", de.StatusCode, de.Message, baseException.Message);
}
catch (Exception e)
{
Exception baseException = e.GetBaseException();
Console.WriteLine("Error: {0}, Message: {1}", e.Message, baseException.Message);
}
finally
{
Console.WriteLine("End of demo, press any key to exit.");
Console.ReadKey();
}
}
开发者ID:Rarve,项目名称:FRES,代码行数:30,代码来源:Loader.cs
示例14: DocumentDBDataProvider
public DocumentDBDataProvider(string endpoint, string authorizationKey, string databaseId = "ojibwe")
{
Client = new DocumentClient(new Uri(endpoint), authorizationKey);
_databaseId = databaseId;
if(!Initialize())
throw new ApplicationException("Could not initialize DataProvider");
}
开发者ID:aluitink,项目名称:Ojibwe,代码行数:7,代码来源:DocumentDBDataProvider.cs
示例15: DeleteDatabase
protected static void DeleteDatabase()
{
using (var client = new DocumentClient(new Uri(UnitTestsConfig.EndPoint), UnitTestsConfig.AuthorizationKey))
{
DatabaseService.DeleteDatabase(client, UnitTestsConfig.Database).Wait();
}
}
开发者ID:softwarejc,项目名称:documentdb-backups-csharp,代码行数:7,代码来源:DocumentDBTestsBase.cs
示例16: GetDocumentDbClient
private async Task<DocumentClient> GetDocumentDbClient()
{
var client = new DocumentClient(new Uri(_endPointUrl), _authorizationKKry);
var database = client.CreateDatabaseQuery().
Where(db => db.Id == DocumentDbId).AsEnumerable().FirstOrDefault();
if (database == null)
{
database = await client.CreateDatabaseAsync(
new Database
{
Id = DocumentDbId
});
}
DocumentCollection = client.CreateDocumentCollectionQuery
("dbs/" + database.Id).Where(c => c.Id == _collectionId).AsEnumerable().FirstOrDefault();
if (DocumentCollection == null)
{
DocumentCollection = await client.CreateDocumentCollectionAsync("dbs/" + DocumentDbId,
new DocumentCollection
{
Id = _collectionId
});
}
return client;
}
开发者ID:sogeti,项目名称:Site-provisioning,代码行数:32,代码来源:SiteTemplateRepository.cs
示例17: DatabaseAccountNode
public DatabaseAccountNode(string endpointName, DocumentClient client)
{
this.accountEndpoint = endpointName;
this.Text = endpointName;
this.ImageKey = "DatabaseAccount";
this.SelectedImageKey = "DatabaseAccount";
this.client = client;
this.Tag = "This represents the DatabaseAccount. Right click to add Database";
this.Nodes.Add(new OffersNode(this.client));
MenuItem myMenuItem = new MenuItem("Create Database");
myMenuItem.Click += new EventHandler(myMenuItemAddDatabase_Click);
this.contextMenu.MenuItems.Add(myMenuItem);
MenuItem myMenuItem1 = new MenuItem("Refresh Databases feed");
myMenuItem1.Click += new EventHandler((sender, e) => Refresh(true));
this.contextMenu.MenuItems.Add(myMenuItem1);
MenuItem myMenuItem4 = new MenuItem("Query Database");
myMenuItem4.Click += new EventHandler(myMenuItemQueryDatabase_Click);
this.contextMenu.MenuItems.Add(myMenuItem4);
this.contextMenu.MenuItems.Add("-");
MenuItem myMenuItem2 = new MenuItem("Remove setting");
myMenuItem2.Click += new EventHandler(myMenuItemRemoveDatabaseAccount_Click);
this.contextMenu.MenuItems.Add(myMenuItem2);
MenuItem myMenuItem3 = new MenuItem("Change setting");
myMenuItem3.Click += new EventHandler(myMenuItemChangeSetting_Click);
this.contextMenu.MenuItems.Add(myMenuItem3);
}
开发者ID:casparjones,项目名称:DocumentDBStudio,代码行数:35,代码来源:TreeNodes.cs
示例18: DocumentDBDataReader
public DocumentDBDataReader()
{
var dict = new Dictionary<HighchartsHelper.DocumentTypes, IEnumerable<Document>>();
_documentClient = new DocumentClient(new Uri(ConfigurationManager.AppSettings["DocumentServiceEndpoint"]), ConfigurationManager.AppSettings["DocumentKey"]);
_database = _documentClient.CreateDatabaseQuery().Where(db => db.Id == ConfigurationManager.AppSettings["DocumentDatabase"]).AsEnumerable().FirstOrDefault();
if (_database == null)
throw new ApplicationException("Error: DocumentDB database does not exist");
// Check to verify a document collection with the id=FamilyCollection does not exist
_documentCollection = _documentClient.CreateDocumentCollectionQuery(_database.CollectionsLink).Where(c => c.Id == ConfigurationManager.AppSettings["DocumentCollection"]).AsEnumerable().FirstOrDefault();
if (_documentCollection == null)
throw new ApplicationException("Error: DocumentDB collection does not exist");
try
{
_documentClient.CreateUserDefinedFunctionAsync(_documentCollection.SelfLink, new UserDefinedFunction
{
Id = "ISDEFINED",
Body = @"function ISDEFINED(doc, prop) {
return doc[prop] !== undefined;
}"
});
}
catch (Exception)
{
//fail silently for now..
}
}
开发者ID:Rodrigossz,项目名称:CloudDataCamp,代码行数:32,代码来源:DocumentDBDataReader.cs
示例19: CreateDocumentCollection
private static async Task<DocumentCollection> CreateDocumentCollection(DocumentClient client, Database database, string collectionId)
{
var collectionSpec = new DocumentCollection { Id = collectionId };
var requestOptions = new RequestOptions { OfferType = "S1" };
return await client.CreateDocumentCollectionAsync(database.SelfLink, collectionSpec, requestOptions);
}
开发者ID:paulhoulston,项目名称:IssueTracker,代码行数:7,代码来源:DocumentDbCollection.cs
示例20: GetStart
//new add
private static async Task GetStart()
{
var client = new DocumentClient(new Uri(EndpointURL), AuthorizationKey);
database = client.CreateDatabaseQuery().Where(d => d.Id == "ppweict").AsEnumerable().FirstOrDefault();
collection = client.CreateDocumentCollectionQuery(database.SelfLink).Where(c => c.Id == "Exam_Pool").AsEnumerable().FirstOrDefault();
var EfDs = client.CreateDocumentQuery(collection.DocumentsLink, "SELECT * FROM Exam_pool f WHERE f.verify = \"true\" ");
foreach (exam_pool EfD in EfDs)
{
Console.WriteLine(EfD);
exams.Add(new exam_pool
{
id = EfD.id,
exam_catrgory = EfD.exam_catrgory,
exam_level = EfD.exam_level,
questions = EfD.questions,
answer_A = EfD.answer_A,
answer_B = EfD.answer_B,
answer_C = EfD.answer_C,
answer_D = EfD.answer_D,
answer_E = EfD.answer_E,
C_answer = EfD.C_answer,
exam_link = EfD.exam_link,
lang = EfD.lang,
verify = EfD.verify,
});
}
}
开发者ID:Steven-Tsai,项目名称:ppweict_Web_API,代码行数:31,代码来源:exam_pool_1_Repository.cs
注:本文中的Microsoft.Azure.Documents.Client.DocumentClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论