本文整理汇总了C#中BrightstarDB.Client.EmbeddedDataObjectContext.OpenStore方法的典型用法代码示例。如果您正苦于以下问题:C# EmbeddedDataObjectContext.OpenStore方法的具体用法?C# EmbeddedDataObjectContext.OpenStore怎么用?C# EmbeddedDataObjectContext.OpenStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BrightstarDB.Client.EmbeddedDataObjectContext
的用法示例。
在下文中一共展示了EmbeddedDataObjectContext.OpenStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetDataObjectStore
private static IDataObjectStore GetDataObjectStore(string storeName)
{
var context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
if (!context.DoesStoreExist(storeName))
{
return context.CreateStore(storeName);
}
return context.OpenStore(storeName);
}
示例2: TestOpenDataObjectStore
public void TestOpenDataObjectStore()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
Assert.IsNotNull(context);
var storeName = Guid.NewGuid().ToString();
var store = context.CreateStore(storeName);
Assert.IsNotNull(store);
store = context.OpenStore(storeName);
Assert.IsNotNull(store);
}
示例3: TestRemoveSpecificValueProperty
public void TestRemoveSpecificValueProperty()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var storeId = Guid.NewGuid().ToString();
var store = context.CreateStore(storeId);
var p1 = store.MakeDataObject();
Assert.IsNotNull(p1);
var ageType = store.MakeDataObject("http://www.np.com/label");
p1.AddProperty(ageType, "graham");
p1.AddProperty(ageType, "kal");
store.SaveChanges();
store = context.OpenStore(storeId);
var p2 = store.GetDataObject(p1.Identity);
Assert.AreEqual(2, ((DataObject)p2).Triples.Count());
var propValues = p2.GetPropertyValues("http://www.np.com/label").Cast<string>();
Assert.IsNotNull(propValues);
Assert.AreEqual(2, propValues.Count());
// remove it
p2.RemoveProperty(ageType, "kal");
store.SaveChanges();
Assert.AreEqual(1, ((DataObject)p2).Triples.Count());
store = context.OpenStore(storeId);
var p3 = store.GetDataObject(p1.Identity);
Assert.AreEqual(1, ((DataObject)p3).Triples.Count());
var label = p3.GetPropertyValue(ageType);
Assert.IsNotNull(label);
Assert.AreEqual("graham", label);
}
示例4: TestCurieObjectGetPropertyPersisted
public void TestCurieObjectGetPropertyPersisted()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var storeId = Guid.NewGuid().ToString();
context.CreateStore(storeId);
var store = context.OpenStore(storeId,
new Dictionary<string, string> { { "np", "http://www.np.com/" } });
var p1 = store.MakeDataObject();
Assert.IsNotNull(p1);
//object type
var productType = store.MakeDataObject("http://www.networkedplanet.com/schemas/product");
p1.SetType(productType);
var labelType = store.MakeDataObject("np:label");
p1.AddProperty(labelType, "graham");
store.SaveChanges();
store = context.OpenStore(storeId,
new Dictionary<string, string> { { "np", "http://www.np.com/" } });
var p2 = store.GetDataObject(p1.Identity);
var label = p2.GetPropertyValue(labelType);
Assert.IsNotNull(label);
Assert.AreEqual("graham", label);
var label2 = p2.GetPropertyValue("np:label");
Assert.IsNotNull(label2);
Assert.AreEqual("graham", label2);
}
示例5: TestCurieObjectGetProperty
public void TestCurieObjectGetProperty()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var storeId = Guid.NewGuid().ToString();
context.CreateStore(storeId);
var store = context.OpenStore(storeId,
new Dictionary<string, string> { { "np", "http://www.np.com/" } });
var p1 = store.MakeDataObject();
Assert.IsNotNull(p1);
var labelType = store.MakeDataObject("np:label");
p1.AddProperty(labelType, "graham");
store.SaveChanges();
var p2 = store.GetDataObject(p1.Identity);
Assert.AreEqual(1, ((DataObject)p2).Triples.Count());
var label = p2.GetPropertyValue(labelType);
Assert.IsNotNull(label);
Assert.AreEqual("graham", label);
}
示例6: TestDataObjectDeleteObjectsUsedInProperties
public void TestDataObjectDeleteObjectsUsedInProperties()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var storeId = Guid.NewGuid().ToString();
var store = context.CreateStore(storeId);
//Categories
var categoryType = store.MakeDataObject("http://www.networkedplanet.com/schemas/category");
var nosql = store.MakeDataObject("http://www.networkedplanet.com/categories/nosql");
nosql.SetType(categoryType);
var dotnet = store.MakeDataObject("http://www.networkedplanet.com/categories/.net");
dotnet.SetType(categoryType);
var rdf = store.MakeDataObject("http://www.networkedplanet.com/categories/rdf");
rdf.SetType(categoryType);
var topicmaps = store.MakeDataObject("http://www.networkedplanet.com/categories/topicmaps");
topicmaps.SetType(categoryType);
store.SaveChanges();
store = context.OpenStore(storeId);
var allCategories = store.BindDataObjectsWithSparql("SELECT ?cat WHERE {?cat a <http://www.networkedplanet.com/schemas/category>}").ToList();
Assert.IsNotNull(allCategories);
Assert.AreEqual(4, allCategories.Count);
foreach (var c in allCategories)
{
c.Delete();
}
store.SaveChanges();
store = context.OpenStore(storeId);
allCategories = store.BindDataObjectsWithSparql("SELECT ?cat WHERE {?cat a <http://www.networkedplanet.com/schemas/category>}").ToList();
Assert.IsNotNull(allCategories);
Assert.AreEqual(0, allCategories.Count); // all categories have been deleted
nosql = store.GetDataObject("http://www.networkedplanet.com/categories/nosql");
Assert.AreEqual(0, ((DataObject)nosql).Triples.Count());
}
示例7: TestDataObjectProperties
public void TestDataObjectProperties()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var storeId = Guid.NewGuid().ToString();
var store = context.CreateStore(storeId);
//products
var productType = store.MakeDataObject("http://www.networkedplanet.com/schemas/product");
var brightstarDb = store.MakeDataObject("http://www.networkedplanet.com/products/brightstar");
brightstarDb.SetType(productType);
//properties
var name = store.MakeDataObject("http://www.networkedplanet.com/schemas/product/name");
brightstarDb.SetProperty(name, "Brightstar DB");
store.SaveChanges();
store = context.OpenStore(storeId);
brightstarDb = store.GetDataObject("http://www.networkedplanet.com/products/brightstar");
Assert.IsNotNull(brightstarDb);
Assert.IsNotNull(brightstarDb.GetPropertyValue(name));
}
示例8: TestRemoveProperty2
public void TestRemoveProperty2()
{
var storeId = Guid.NewGuid().ToString();
const string data = @"<http://www.np.com/objects/1> <http://www.np.com/types/p1> <http://www.np.com/objects/2> .
<http://www.np.com/objects/3> <http://www.np.com/types/p1> <http://www.np.com/objects/4> .";
InitializeStore(storeId, data);
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var store = context.OpenStore(storeId);
var obj1 = store.GetDataObject("http://www.np.com/objects/1");
var obj1Related = obj1.GetPropertyValues("http://www.np.com/types/p1").OfType<IDataObject>().ToList();
var obj3 = store.GetDataObject("http://www.np.com/objects/3");
var obj3Related = obj3.GetPropertyValues("http://www.np.com/types/p1").OfType<IDataObject>().ToList();
Assert.AreEqual(1, obj1Related.Count());
Assert.IsTrue(obj1Related.Any(r=>r.Identity.Equals("http://www.np.com/objects/2")));
Assert.AreEqual(1, obj3Related.Count());
Assert.IsTrue(obj3Related.Any(r => r.Identity.Equals("http://www.np.com/objects/4")));
obj3.AddProperty("http://www.np.com/types/p1", store.MakeDataObject("http://www.np.com/objects/5"));
obj1.RemovePropertiesOfType("http://www.np.com/types/p1");
obj1Related = obj1.GetPropertyValues("http://www.np.com/types/p1").OfType<IDataObject>().ToList();
obj3Related = obj3.GetPropertyValues("http://www.np.com/types/p1").OfType<IDataObject>().ToList();
Assert.AreEqual(0, obj1Related.Count());
Assert.AreEqual(2, obj3Related.Count());
Assert.IsTrue(obj3Related.Any(r => r.Identity.Equals("http://www.np.com/objects/4")));
Assert.IsTrue(obj3Related.Any(r => r.Identity.Equals("http://www.np.com/objects/5")));
store.SaveChanges();
obj1 = store.GetDataObject("http://www.np.com/objects/1");
obj1Related = obj1.GetPropertyValues("http://www.np.com/types/p1").OfType<IDataObject>().ToList();
obj3 = store.GetDataObject("http://www.np.com/objects/3");
obj3Related = obj3.GetPropertyValues("http://www.np.com/types/p1").OfType<IDataObject>().ToList();
Assert.AreEqual(0, obj1Related.Count());
Assert.AreEqual(2, obj3Related.Count());
Assert.IsTrue(obj3Related.Any(r => r.Identity.Equals("http://www.np.com/objects/4")));
Assert.IsTrue(obj3Related.Any(r => r.Identity.Equals("http://www.np.com/objects/5")));
}
示例9: TestSavedDataObjectPropertyIsSameAfterSave
public void TestSavedDataObjectPropertyIsSameAfterSave()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
Assert.IsNotNull(context);
var storeName = Guid.NewGuid().ToString();
var store = context.CreateStore(storeName);
Assert.IsNotNull(store);
var p1 = store.MakeDataObject();
Assert.IsNotNull(p1);
var labelType = store.MakeDataObject("http://www.np.com/label");
p1.SetProperty(labelType, "graham");
store.SaveChanges();
store = context.OpenStore(storeName);
var p2 = store.GetDataObject(p1.Identity);
Assert.IsNotNull(p2);
Assert.AreEqual(p1.Identity, p2.Identity);
var label = p2.GetPropertyValue(labelType);
Assert.AreEqual("graham", label);
}
示例10: TestCreateDataObjectWithCurie
public void TestCreateDataObjectWithCurie()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
Assert.IsNotNull(context);
var storeName = Guid.NewGuid().ToString();
var store = context.CreateStore(storeName);
Assert.IsNotNull(store);
store = context.OpenStore(storeName, new Dictionary<string, string> { { "people", "http://www.networkedplanet.com/people/" } });
Assert.IsNotNull(store);
var p1 = store.MakeDataObject("people:gra");
Assert.IsNotNull(p1);
Assert.AreEqual("http://www.networkedplanet.com/people/gra", p1.Identity);
}
示例11: TestOpenDataObjectStoreWithNamespaceMappings
public void TestOpenDataObjectStoreWithNamespaceMappings()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
Assert.IsNotNull(context);
var storeName = Guid.NewGuid().ToString();
var store = context.CreateStore(storeName);
Assert.IsNotNull(store);
store = context.OpenStore(storeName, new Dictionary<string, string> { {"people", "http://www.networkedplanet.com/people/"}});
Assert.IsNotNull(store);
}
示例12: TestRefreshSingleStoreWins
public void TestRefreshSingleStoreWins()
{
IDataObjectContext context =
new EmbeddedDataObjectContext(
new ConnectionString("type=embedded;optimisticLocking=true;storesDirectory=" +
Configuration.StoreLocation + "\\"));
var storeName = Guid.NewGuid().ToString();
var store1 = context.CreateStore(storeName);
var store1Alice = store1.MakeDataObject("http://example.org/alice");
store1Alice.SetProperty("http://example.org/age", 21);
store1.SaveChanges();
var store2 = context.OpenStore(storeName);
var store2Alice = store2.GetDataObject("http://example.org/alice");
store2Alice.SetProperty("http://example.org/age", 22);
store2.SaveChanges();
store1Alice.SetProperty("http://example.org/age", 20);
try
{
store1.SaveChanges();
Assert.Fail("Expected a TransactionPreconditionsFailed exception");
}
catch (TransactionPreconditionsFailedException)
{
// Expected
store1.Refresh(RefreshMode.StoreWins, store1Alice);
Assert.AreEqual(22, store1Alice.GetPropertyValue("http://example.org/age"));
store1.SaveChanges();
// Should have forced the update through
var store3 = context.OpenStore(storeName);
var store3Alice = store3.GetDataObject(store1Alice.Identity);
Assert.AreEqual(22, store3Alice.GetPropertyValue("http://example.org/age"));
}
}
示例13: TestPreconditionsFailedException
public void TestPreconditionsFailedException()
{
IDataObjectContext context =
new EmbeddedDataObjectContext(
new ConnectionString("type=embedded;optimisticLocking=true;storesDirectory=" +
Configuration.StoreLocation + "\\"));
var storeName = Guid.NewGuid().ToString();
var store1 = context.CreateStore(storeName);
var store1Alice = store1.MakeDataObject("http://example.org/alice");
store1Alice.SetProperty("http://example.org/age", 21);
store1.SaveChanges();
var store2 = context.OpenStore(storeName);
var store2Alice = store2.GetDataObject("http://example.org/alice");
store2Alice.SetProperty("http://example.org/age", 22);
store2.SaveChanges();
store1Alice.SetProperty("http://example.org/age", 20);
try
{
store1.SaveChanges();
Assert.Fail("Expected a TransactionPreconditionsFailed exception");
}
catch (TransactionPreconditionsFailedException ex)
{
// Expected
Assert.AreEqual(1, ex.InvalidSubjects.Count());
Assert.AreEqual("http://example.org/alice", ex.InvalidSubjects.First());
}
}
示例14: TestQueryGreaterThan
public void TestQueryGreaterThan()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var storeName = Guid.NewGuid().ToString();
context.CreateStore(storeName);
Dictionary<string, string> namespaceMappings;
SetUpData(context, storeName, out namespaceMappings);
var store = context.OpenStore(storeName, namespaceMappings);
const string highPay = "SELECT ?p ?s WHERE { ?p a <http://example.org/schema/person> . ?p <http://example.org/schema/salary> ?s . FILTER (?s>50000) }";
var sparqlResult = store.ExecuteSparql(highPay);
Assert.IsNotNull(sparqlResult);
var result = sparqlResult.ResultDocument;
Assert.AreEqual(5, result.SparqlResultRows().Count());
}
示例15: TestRemoveLiteralProperty
public void TestRemoveLiteralProperty()
{
IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
var storeId = Guid.NewGuid().ToString();
var store = context.CreateStore(storeId);
var p1 = store.MakeDataObject();
var p2 = store.MakeDataObject();
var o1 = store.MakeDataObject();
o1.AddProperty(p1, "graham");
o1.AddProperty(p2, 23);
var o2 = store.MakeDataObject();
o2.AddProperty(p1, "bob");
o2.AddProperty(p2, 24);
o2.RemoveProperty(p1, "bob");
store.SaveChanges();
store = context.OpenStore(storeId);
var o3 = store.GetDataObject(o1.Identity);
var o4 = store.GetDataObject(o2.Identity);
Assert.AreEqual("graham", o3.GetPropertyValue(p1));
Assert.AreEqual(23, o3.GetPropertyValue(p2));
Assert.AreEqual(24, o4.GetPropertyValue(p2));
Assert.IsNull(o4.GetPropertyValue(p1));
}