当前位置: 首页>>代码示例>>C#>>正文


C# EmbeddedDataObjectContext.CreateStore方法代码示例

本文整理汇总了C#中BrightstarDB.Client.EmbeddedDataObjectContext.CreateStore方法的典型用法代码示例。如果您正苦于以下问题:C# EmbeddedDataObjectContext.CreateStore方法的具体用法?C# EmbeddedDataObjectContext.CreateStore怎么用?C# EmbeddedDataObjectContext.CreateStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BrightstarDB.Client.EmbeddedDataObjectContext的用法示例。


在下文中一共展示了EmbeddedDataObjectContext.CreateStore方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestCreateDataObjectStore

 public void TestCreateDataObjectStore()
 {
     IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
     Assert.IsNotNull(context);
     var store = context.CreateStore(Guid.NewGuid().ToString());
     Assert.IsNotNull(store);
 }
开发者ID:jaensen,项目名称:BrightstarDB,代码行数:7,代码来源:DataObjectTests.cs

示例2: 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);
 }
开发者ID:rharrisxtheta,项目名称:BrightstarDB,代码行数:9,代码来源:LiteralPropertiesTests.cs

示例3: TestDataObjectFluentApi

        public void TestDataObjectFluentApi()
        {
            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>
                                                       { { "ont", "http://www.networkedplanet.com/types/" }, 
                                                                               { "rdfs", "http://www.w3.org/2000/01/rdf-schema#" },
                                                                               { "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"} });

            var gra = store.MakeDataObject()
                        .SetType(store.MakeDataObject("http://www.networkedplanet.com/types/person"))
                        .SetProperty(store.MakeDataObject("http://www.networkedplanet.com/types/age"), 23)
                        .SetProperty(store.MakeDataObject("http://www.networkedplanet.com/types/worksfor"), 
                                        store.MakeDataObject("http://www.networkedplanet.com/companies/np")
                                     );
            Assert.IsNotNull(gra);

            var kal = store.MakeDataObject()
                        .SetType(store.MakeDataObject("http://www.networkedplanet.com/types/person"))
                        .SetProperty("ont:age", 23)
                        .SetProperty("rdfs:label", "Kal")
                        .SetProperty("ont:worksfor",
                                        store.MakeDataObject("http://www.networkedplanet.com/companies/np")
                                            .SetProperty("rdfs:label", "Networked Planet")
                                     )
                        .SetProperty("ont:email", store.MakeListDataObject(new List<string> { "[email protected]"}));
            Assert.IsNotNull(kal);

            store.SaveChanges();
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:31,代码来源:DataObjectTests.cs

示例4: 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());
            

        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:43,代码来源:DataObjectTests.cs

示例5: 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));

        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:24,代码来源:DataObjectTests.cs

示例6: TestGetRelatedProxiesWithSafeCurie

        public void TestGetRelatedProxiesWithSafeCurie()
        {
            IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
            var storeId = Guid.NewGuid().ToString();
            var store = context.CreateStore(storeId, new Dictionary<string, string>
                                                         {
                                                             {"ont", "http://www.networkedplanet.com/types/"},
                                                             {"rdfs", "http://www.w3.org/2000/01/rdf-schema#"},
                                                             {"rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}
                                                         });

            var p1 = store.MakeDataObject().AddProperty("rdfs:label", "networkedplanet");
            var p2 = store.MakeDataObject().AddProperty("rdfs:label", "gra").AddProperty("ont:worksfor", p1);
            store.SaveChanges();

            store = context.OpenStore(storeId, new Dictionary<string, string>
                                                   {
                                                       {"ont", "http://www.networkedplanet.com/types/"},
                                                       {"rdfs", "http://www.w3.org/2000/01/rdf-schema#"},
                                                       {"rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"}
                                                   });

            var p3 = store.GetDataObject(p2.Identity);
            Assert.IsNotNull(p3);

            var related = p3.GetPropertyValues("[ont:worksfor]").OfType<IDataObject>().ToList();
            Assert.AreEqual(1, related.Count());

            var np = related.FirstOrDefault();
            Assert.IsNotNull(np);
            Assert.AreEqual(p1.Identity, np.Identity);
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:32,代码来源:DataObjectTests.cs

示例7: TestSetPropertyDataObject

        public void TestSetPropertyDataObject()
        {
            IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
            var store = context.CreateStore(Guid.NewGuid().ToString());

            var p1 = store.MakeDataObject();
            var p2 = store.MakeDataObject();
            Assert.IsNotNull(p1);
            var classificationType = store.MakeDataObject("http://www.np.com/classification");
            p1.SetProperty(classificationType, p1);
            p1.SetProperty(classificationType, p2);

            store.SaveChanges();

            var p3 = store.GetDataObject(p1.Identity);
            Assert.AreEqual(1, ((DataObject)p3).Triples.Count());                        
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:17,代码来源:DataObjectTests.cs

示例8: 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);
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:20,代码来源:DataObjectTests.cs

示例9: TestCreateDataObject

 public void TestCreateDataObject()
 {
     IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
     Assert.IsNotNull(context);
     var store = context.CreateStore(Guid.NewGuid().ToString());
     Assert.IsNotNull(store);
     var p1 = store.MakeDataObject();
     Assert.IsNotNull(p1);
     Assert.AreEqual(0, ((DataObject)p1).Triples.Count());
 }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:10,代码来源:DataObjectTests.cs

示例10: TestCreateDataObjectWithString

 public void TestCreateDataObjectWithString()
 {
     IDataObjectContext context = new EmbeddedDataObjectContext(new ConnectionString("type=embedded;storesDirectory=" + Configuration.StoreLocation + "\\"));
     Assert.IsNotNull(context);
     var store = context.CreateStore(Guid.NewGuid().ToString());
     Assert.IsNotNull(store);
     var p1 = store.MakeDataObject("http://www.networkedplanet.com/people/gra");
     Assert.IsNotNull(p1);
 }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:9,代码来源:DataObjectTests.cs

示例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);
 }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:10,代码来源:DataObjectTests.cs

示例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"));
            }
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:36,代码来源:DataObjectTests.cs

示例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());
            }
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:30,代码来源:DataObjectTests.cs

示例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());
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:18,代码来源:DataObjectTests.cs

示例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));
        }
开发者ID:stangelandcl,项目名称:BrightstarDB,代码行数:30,代码来源:DataObjectTests.cs


注:本文中的BrightstarDB.Client.EmbeddedDataObjectContext.CreateStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。