本文整理汇总了C#中Arango.Client.ADatabase类的典型用法代码示例。如果您正苦于以下问题:C# ADatabase类的具体用法?C# ADatabase怎么用?C# ADatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ADatabase类属于Arango.Client命名空间,在下文中一共展示了ADatabase类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Issue_No16_SortedList
public void Issue_No16_SortedList()
{
Database.CreateTestCollection(Database.TestDocumentCollectionName, ACollectionType.Document);
var db = new ADatabase(Database.Alias);
var entity = new IssueNo16Entity();
entity.SortedList = new SortedList<int, bool>();
entity.SortedList.Add(1, true);
entity.SortedList.Add(2, false);
entity.SortedList.Add(3, false);
entity.SortedList.Add(4, false);
var createResult = db.Document.Create(Database.TestDocumentCollectionName, entity);
Assert.IsTrue(createResult.Success);
var getResult = db.Document.Get<IssueNo16Entity>(createResult.Value.ID());
Assert.IsTrue(getResult.Success);
Assert.IsTrue(getResult.HasValue);
for (int i = 0; i < getResult.Value.SortedList.Count; i++)
{
Assert.AreEqual(entity.SortedList.ElementAt(i).Key, getResult.Value.SortedList.ElementAt(i).Key);
Assert.AreEqual(entity.SortedList.ElementAt(i).Value, getResult.Value.SortedList.ElementAt(i).Value);
}
}
开发者ID:yojimbo87,项目名称:ArangoDB-NET,代码行数:27,代码来源:IssueTests.cs
示例2: Should_execute_AQL_query_with_batchSize
public void Should_execute_AQL_query_with_batchSize()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var doc3 = new Dictionary<string, object>()
.String("foo", "foo string 3");
db.Document
.Create(Database.TestDocumentCollectionName, doc3);
var doc4 = new Dictionary<string, object>()
.String("foo", "foo string 4");
db.Document
.Create(Database.TestDocumentCollectionName, doc4);
var queryResult = db.Query
.BatchSize(1)
.Aql(string.Format(@"
FOR item IN {0}
RETURN item
", Database.TestDocumentCollectionName))
.ToList();
Assert.AreEqual(200, queryResult.StatusCode);
Assert.IsTrue(queryResult.Success);
Assert.IsTrue(queryResult.HasValue);
Assert.AreEqual(queryResult.Value.Count, 4);
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:30,代码来源:QueryOperationsTests.cs
示例3: Issue_No15_List_save_and_retrieve
public void Issue_No15_List_save_and_retrieve()
{
Database.CreateTestCollection(Database.TestDocumentCollectionName, ACollectionType.Document);
var db = new ADatabase(Database.Alias);
var entity = new IssueNo15Entity();
entity.ListNumbers = new List<int> { 1, 2, 3 };
entity.ArrayNumbers = new int[] { 4, 5, 6};
var createResult = db.Document.Create(Database.TestDocumentCollectionName, entity);
Assert.IsTrue(createResult.Success);
var getresult = db.Document.Get<IssueNo15Entity>(createResult.Value.ID());
Assert.IsTrue(getresult.Success);
Assert.IsTrue(getresult.HasValue);
for (int i = 0; i < getresult.Value.ListNumbers.Count; i++)
{
Assert.AreEqual(entity.ListNumbers[i], getresult.Value.ListNumbers[i]);
}
for (int i = 0; i < getresult.Value.ArrayNumbers.Length; i++)
{
Assert.AreEqual(entity.ArrayNumbers[i], getresult.Value.ArrayNumbers[i]);
}
}
开发者ID:yojimbo87,项目名称:ArangoDB-NET,代码行数:28,代码来源:IssueTests.cs
示例4: Should_replace_function
public void Should_replace_function()
{
Database.CreateTestDatabase(Database.TestDatabaseGeneral);
var db = new ADatabase(Database.Alias);
var registerResult = db.Function.Register(
"myfunctions::temperature::celsiustofahrenheit",
"function (celsius) { return celsius * 1.8 + 40; }"
);
Assert.AreEqual(201, registerResult.StatusCode);
Assert.IsTrue(registerResult.Success);
Assert.IsTrue(registerResult.HasValue);
Assert.IsTrue(registerResult.Value);
var replaceResult = db.Function.Register(
"myfunctions::temperature::celsiustofahrenheit",
"function (celsius) { return celsius * 1.8 + 32; }"
);
Assert.AreEqual(200, replaceResult.StatusCode);
Assert.IsTrue(replaceResult.Success);
Assert.IsTrue(replaceResult.HasValue);
Assert.IsTrue(replaceResult.Value);
const int celsius = 30;
const float fahrenheit = celsius * 1.8f + 32;
var queryResult = db.Query
.BindVar("celsius", celsius)
.Aql("return myfunctions::temperature::celsiustofahrenheit(@celsius)")
.ToList<float>();
Assert.AreEqual(fahrenheit, queryResult.Value.First());
}
开发者ID:yojimbo87,项目名称:ArangoDB-NET,代码行数:35,代码来源:FunctionOperationsTests.cs
示例5: Should_change_collection_properties
public void Should_change_collection_properties()
{
Database.CreateTestDatabase(Database.TestDatabaseGeneral);
var db = new ADatabase(Database.Alias);
var createResult = db.Collection
.Create(Database.TestDocumentCollectionName);
const long journalSize = 199999999;
var operationResult = db.Collection
.WaitForSync(true)
.JournalSize(journalSize)
.ChangeProperties(createResult.Value.String("name"));
Assert.AreEqual(200, operationResult.StatusCode);
Assert.IsTrue(operationResult.Success);
Assert.IsTrue(operationResult.HasValue);
Assert.AreEqual(createResult.Value.String("id"), operationResult.Value.String("id"));
Assert.AreEqual(createResult.Value.String("name"), operationResult.Value.String("name"));
Assert.AreEqual(createResult.Value.Bool("isSystem"), operationResult.Value.Bool("isSystem"));
Assert.AreEqual(createResult.Value.Int("status"), operationResult.Value.Int("status"));
Assert.AreEqual(createResult.Value.Int("type"), operationResult.Value.Int("type"));
Assert.IsFalse(operationResult.Value.Bool("isVolatile"));
Assert.IsTrue(operationResult.Value.Bool("doCompact"));
Assert.AreEqual(AKeyGeneratorType.Traditional, operationResult.Value.Enum<AKeyGeneratorType>("keyOptions.type"));
Assert.IsTrue(operationResult.Value.Bool("keyOptions.allowUserKeys"));
Assert.IsTrue(operationResult.Value.Bool("waitForSync"));
Assert.IsTrue(operationResult.Value.Long("journalSize") == journalSize);
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:31,代码来源:CollectionOperationsTests.cs
示例6: Should_list_functions
public void Should_list_functions()
{
Database.CreateTestDatabase(Database.TestDatabaseGeneral);
var db = new ADatabase(Database.Alias);
const string name1 = "myfunctions::temperature::celsiustofahrenheit1";
const string code1 = "function (celsius) { return celsius * 1.8 + 40; }";
var registerResult1 = db.Function.Register(name1, code1);
Assert.AreEqual(true, registerResult1.Success);
const string name2 = "myfunctions::temperature::celsiustofahrenheit2";
const string code2 = "function (celsius) { return celsius * 1.8 + 32; }";
var registerResult2 = db.Function.Register(name2, code2);
Assert.AreEqual(true, registerResult2.Success);
var listResult = db.Function.List();
Assert.AreEqual(200, listResult.StatusCode);
Assert.IsTrue(listResult.Success);
Assert.IsTrue(listResult.HasValue);
Assert.AreEqual(2, listResult.Value.Count);
// retrieved order of the functions seems to be reversed
Assert.AreEqual(name2, listResult.Value[0].String("name"));
Assert.AreEqual(code2, listResult.Value[0].String("code"));
Assert.AreEqual(name1, listResult.Value[1].String("name"));
Assert.AreEqual(code1, listResult.Value[1].String("code"));
}
开发者ID:yojimbo87,项目名称:ArangoDB-NET,代码行数:29,代码来源:FunctionOperationsTests.cs
示例7: Should_execute_AQL_query_fluent
public void Should_execute_AQL_query_fluent()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var useCount = true;
var useBatchSize = true;
var queryOperation = db.Query
.Aql(string.Format(@"
FOR item IN {0}
RETURN item
", Database.TestDocumentCollectionName));
if (useCount)
{
queryOperation.Count(true);
}
if (useBatchSize)
{
queryOperation.BatchSize(1);
}
var queryResult = queryOperation.ToList();
Assert.AreEqual(200, queryResult.StatusCode);
Assert.IsTrue(queryResult.Success);
Assert.IsTrue(queryResult.HasValue);
Assert.AreEqual(queryResult.Value.Count, 2);
Assert.AreEqual(queryResult.Extra.Long("count"), 2);
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:31,代码来源:QueryOperationsTests.cs
示例8: Should_execute_get_foxx_request
public void Should_execute_get_foxx_request()
{
var db = new ADatabase(Database.SystemAlias);
var getResult = db.Foxx.Get<Dictionary<string, object>>("/getting-started/hello-world");
Assert.AreEqual(200, getResult.StatusCode);
Assert.AreEqual("bar", getResult.Value.String("foo"));
}
开发者ID:yojimbo87,项目名称:ArangoDB-NET,代码行数:8,代码来源:FoxxOperationsTests.cs
示例9: Should_check_document
public void Should_check_document()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var checkResult = db.Document
.Check(documents[0].String("_id"));
Assert.AreEqual(200, checkResult.StatusCode);
Assert.IsTrue(checkResult.Success);
Assert.IsTrue(checkResult.HasValue);
Assert.AreEqual(checkResult.Value, documents[0].String("_rev"));
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:13,代码来源:DocumentOperationsTests.cs
示例10: Should_create_database
public void Should_create_database()
{
Database.CleanupTestDatabases();
var db = new ADatabase(Database.SystemAlias);
var createResult = db.Create(Database.TestDatabaseOneTime);
Assert.AreEqual(201, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.IsTrue(createResult.Value);
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:13,代码来源:DatabaseOperationsTests.cs
示例11: Should_check_document_with_ifMatch_and_return_412
public void Should_check_document_with_ifMatch_and_return_412()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var checkResult = db.Document
.IfMatch("123456789")
.Check(documents[0].String("_id"));
Assert.AreEqual(412, checkResult.StatusCode);
Assert.IsFalse(checkResult.Success);
Assert.IsTrue(checkResult.HasValue);
Assert.AreEqual(checkResult.Value, documents[0].String("_rev"));
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:14,代码来源:DocumentOperationsTests.cs
示例12: Should_execute_post_foxx_request_with_body
public void Should_execute_post_foxx_request_with_body()
{
var db = new ADatabase(Database.SystemAlias);
var body = Dictator.New()
.String("foo", "some string");
var postResult = db.Foxx
.Body(body)
.Post<Dictionary<string, object>>("/getting-started/hello-world");
Assert.AreEqual(200, postResult.StatusCode);
Assert.AreEqual(body.String("foo"), postResult.Value.String("foo"));
}
开发者ID:yojimbo87,项目名称:ArangoDB-NET,代码行数:14,代码来源:FoxxOperationsTests.cs
示例13: Should_check_document_with_ifNoneMatch
public void Should_check_document_with_ifNoneMatch()
{
var documents = Database.ClearCollectionAndFetchTestDocumentData(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var checkResult = db.Document
.IfNoneMatch("123456789")
.Check(documents[0].ID());
Assert.AreEqual(200, checkResult.StatusCode);
Assert.IsTrue(checkResult.Success);
Assert.IsTrue(checkResult.HasValue);
Assert.AreEqual(checkResult.Value, documents[0].Rev());
}
开发者ID:yojimbo87,项目名称:ArangoDB-NET,代码行数:14,代码来源:DocumentOperationsTests.cs
示例14: Should_delete_database
public void Should_delete_database()
{
Database.CleanupTestDatabases();
var db = new ADatabase(Database.SystemAlias);
var createResult = db.Create(Database.TestDatabaseGeneral);
var deleteResult = db.Drop(Database.TestDatabaseGeneral);
Assert.AreEqual(200, deleteResult.StatusCode);
Assert.IsTrue(deleteResult.Success);
Assert.IsTrue(deleteResult.HasValue);
Assert.IsTrue(deleteResult.Value);
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:15,代码来源:DatabaseOperationsTests.cs
示例15: Should_fail_create_already_existing_database
public void Should_fail_create_already_existing_database()
{
Database.CleanupTestDatabases();
var db = new ADatabase(Database.SystemAlias);
var createResult = db.Create(Database.TestDatabaseGeneral);
var createResult2 = db.Create(Database.TestDatabaseGeneral);
Assert.AreEqual(409, createResult2.StatusCode);
Assert.IsFalse(createResult2.Success);
Assert.IsTrue(createResult2.HasValue);
Assert.IsFalse(createResult2.Value);
Assert.IsNotNull(createResult2.Error);
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:16,代码来源:DatabaseOperationsTests.cs
示例16: Should_create_autoincrement_collection
public void Should_create_autoincrement_collection()
{
Database.CreateTestDatabase(Database.TestDatabaseGeneral);
var db = new ADatabase(Database.Alias);
var createResult = db.Collection
.KeyGeneratorType(AKeyGeneratorType.Autoincrement)
.Create(Database.TestDocumentCollectionName);
Assert.AreEqual(200, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.AreEqual(true, createResult.Value.IsString("id"));
Assert.AreEqual(Database.TestDocumentCollectionName, createResult.Value.String("name"));
Assert.AreEqual(false, createResult.Value.Bool("waitForSync"));
Assert.AreEqual(false, createResult.Value.Bool("isVolatile"));
Assert.AreEqual(false, createResult.Value.Bool("isSystem"));
Assert.AreEqual(ACollectionStatus.Loaded, createResult.Value.Enum<ACollectionStatus>("status"));
Assert.AreEqual(ACollectionType.Document, createResult.Value.Enum<ACollectionType>("type"));
// create documents and test if their key are incremented accordingly
var newDocument = new Dictionary<string, object>()
.String("foo", "some string")
.Document("bar", new Dictionary<string, object>().String("foo", "string value"));
var doc1Result = db.Document
.Create(Database.TestDocumentCollectionName, newDocument);
Assert.AreEqual(202, doc1Result.StatusCode);
Assert.IsTrue(doc1Result.Success);
Assert.IsTrue(doc1Result.HasValue);
Assert.AreEqual(Database.TestDocumentCollectionName + "/" + 1, doc1Result.Value.String("_id"));
Assert.AreEqual("1", doc1Result.Value.String("_key"));
Assert.IsFalse(string.IsNullOrEmpty(doc1Result.Value.String("_rev")));
var doc2Result = db.Document
.Create(Database.TestDocumentCollectionName, newDocument);
Assert.AreEqual(202, doc2Result.StatusCode);
Assert.IsTrue(doc2Result.Success);
Assert.IsTrue(doc2Result.HasValue);
Assert.AreEqual(Database.TestDocumentCollectionName + "/" + 2, doc2Result.Value.String("_id"));
Assert.AreEqual("2", doc2Result.Value.String("_key"));
Assert.IsFalse(string.IsNullOrEmpty(doc2Result.Value.String("_rev")));
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:47,代码来源:CollectionOperationsTests.cs
示例17: Should_create_database_with_users
public void Should_create_database_with_users()
{
Database.CleanupTestDatabases();
var db = new ADatabase(Database.SystemAlias);
var users = new List<AUser>()
{
new AUser { Username = "admin", Password = "secret", Active = true },
new AUser { Username = "tester001", Password = "test001", Active = false }
};
var createResult = db.Create(Database.TestDatabaseOneTime, users);
Assert.AreEqual(201, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.IsTrue(createResult.Value);
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:19,代码来源:DatabaseOperationsTests.cs
示例18: Should_create_cap_contraint
public void Should_create_cap_contraint()
{
Database.CreateTestCollection(Database.TestDocumentCollectionName, ACollectionType.Document);
var db = new ADatabase(Database.Alias);
var createResult = db.Index
.Type(AIndexType.Cap)
.Size(10)
.Create(Database.TestDocumentCollectionName);
Assert.AreEqual(201, createResult.StatusCode);
Assert.IsTrue(createResult.Success);
Assert.IsTrue(createResult.HasValue);
Assert.IsTrue(createResult.Value.IsID("id"));
Assert.AreEqual(AIndexType.Cap, createResult.Value.Enum<AIndexType>("type"));
Assert.IsFalse(createResult.Value.Bool("unique"));
Assert.AreEqual(10, createResult.Value.Long("size"));
Assert.AreEqual(0, createResult.Value.Long("byteSize"));
Assert.IsTrue(createResult.Value.Bool("isNewlyCreated"));
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:20,代码来源:IndexOperationsTests.cs
示例19: Should_check_edge
public void Should_check_edge()
{
Database.ClearTestCollection(Database.TestEdgeCollectionName);
var db = new ADatabase(Database.Alias);
var document = new Dictionary<string, object>()
.String("foo", "some string")
.Int("bar", 12345);
var createResult = db.Edge
.Create(Database.TestEdgeCollectionName, _documents[0].String("_id"), _documents[1].String("_id"), document);
var checkResult = db.Edge
.Check(createResult.Value.String("_id"));
Assert.AreEqual(200, checkResult.StatusCode);
Assert.IsTrue(checkResult.Success);
Assert.IsTrue(checkResult.HasValue);
Assert.AreEqual(checkResult.Value, createResult.Value.String("_rev"));
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:20,代码来源:EdgeOperationsTests.cs
示例20: Should_execute_transaction_and_return_document
public void Should_execute_transaction_and_return_document()
{
Database.ClearTestCollection(Database.TestDocumentCollectionName);
var db = new ADatabase(Database.Alias);
var transactionResult = db.Transaction
.WriteCollection(Database.TestDocumentCollectionName)
.Execute<Dictionary<string, object>>(@"
function () {
var db = require('internal').db;
db." + Database.TestDocumentCollectionName + @".save({ });
return { 'Executed': true };
}
");
Assert.AreEqual(200, transactionResult.StatusCode);
Assert.IsTrue(transactionResult.Success);
Assert.IsTrue(transactionResult.HasValue);
Assert.IsTrue(transactionResult.Value.Bool("Executed"));
}
开发者ID:kangkot,项目名称:ArangoDB-NET,代码行数:22,代码来源:TransactionOperationsTests.cs
注:本文中的Arango.Client.ADatabase类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论