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


C# Database.Get方法代码示例

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


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

示例1: TestDatabaseWithLotsOfKeys

        public void TestDatabaseWithLotsOfKeys()
        {
            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);

            using (var db = new Database<TestEntry>("testdb", false))
            {
                for (var i = 0; i < 100000; i++)
                {
                    db.Set(i.ToString(), new TestEntry(Guid.NewGuid().ToString()));
                }

                Assert.IsNotNull(db.Get("5000"));
                Assert.IsNull(db.Get("xxxx"));

                Console.WriteLine($"levels : {db.CurrentLevelNumber}");
            }

            using (var db = new Database<TestEntry>("testdb"))
            {
                Assert.IsNotNull(db.Get("5000"));
                Assert.IsNull(db.Get("xxxx"));
            }

            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);
        }
开发者ID:richorama,项目名称:ra-db,代码行数:25,代码来源:DatabaseTests.cs

示例2: Television

        public Television(TLFeed feed, Database database, Collector collector, Torrenter torrenter)
        {
            feed.New += item =>
            {
                if (item.Categories[0].Name != "Episodes")
                    return;
                var shows = database.Get<Show>();
                if (shows.Any(show => item.Title.Text.ToLower().Contains(show.Title.ToLower())))
                {
                    var model = new Torrent(item.Title.Text, item.Links.First().Uri.ToString(), item.Categories.First().Name);
                    collector.Event(model);
                    torrenter.Download(item.Links.First().Uri.ToString());
                }
            };

            collector.On<Search>(search =>
            {
                var wc = new WebClient();
                var result = wc.DownloadString("http://www.imdb.com/xml/find?json=1&tt=on&q=" + search.Query);
                try
                {

                    var json = JObject.Parse(result);
                    var exact = json["title_popular"];
                    if (exact == null) return;
                    if(!exact["description"].ToString().Contains("TV")) return;
                    var show = new Show(exact[0]["title"].ToString());
                    collector.Event(show);
                }
                catch { }
            });
        }
开发者ID:jarvis-systems,项目名称:Cortex,代码行数:32,代码来源:Television.cs

示例3: Gets

 private static void Gets(Random rand, Database<TestValue> db, Stopwatch timer)
 {
     timer.Start();
     for (var i = 0; i < 300000; i++)
     {
         var key = rand.Next(1, 1000).ToString();
         var value = db.Get(key);
     }
     timer.Stop();
     Console.WriteLine($"get time {timer.ElapsedMilliseconds}ms");
     timer.Reset();
 }
开发者ID:richorama,项目名称:ra-db,代码行数:12,代码来源:Program.cs

示例4: SimpleDatabaseTest

        public void SimpleDatabaseTest()
        {
            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);

            using (var db = new Database<TestEntry>("testdb"))
            {
                db.Set("foo", new TestEntry("bar"));
                Assert.AreEqual("bar", db.Get("foo").Value);
            }

            using (var db = new Database<TestEntry>("testdb"))
            {
                Assert.AreEqual("bar", db.Get("foo").Value);
            }

            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);
        }
开发者ID:richorama,项目名称:ra-db,代码行数:17,代码来源:DatabaseTests.cs

示例5: WriteNulls

        public void WriteNulls()
        {
            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);

            using (var db = new Database<TestClass>("testdb"))
            {
                db.Set("foo", null);

                Assert.IsNull(db.Get("foo"));
            }

            using (var db = new Database<TestClass>("testdb"))
            {
                Assert.IsNull(db.Get("foo"));
            }
        }
开发者ID:richorama,项目名称:ra-db,代码行数:16,代码来源:DatabaseTests.cs

示例6: MultiWrite

        public void MultiWrite()
        {
            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);

            using (var db = new Database<TestEntry>("testdb"))
            {
                var records = new KeyValue<TestEntry>[] {
                    new KeyValue<TestEntry>("one",new TestEntry("1")),
                    new KeyValue<TestEntry>("two",new TestEntry("2")),
                    new KeyValue<TestEntry>("three",new TestEntry("3"))
                };

                db.SetMulti(records);

                Assert.AreEqual("1", db.Get("one").Value);
                Assert.AreEqual("2", db.Get("two").Value);
                Assert.AreEqual("3", db.Get("three").Value);
            }
            using (var db = new Database<TestEntry>("testdb"))
            {
                Assert.AreEqual("1", db.Get("one").Value);
                Assert.AreEqual("2", db.Get("two").Value);
                Assert.AreEqual("3", db.Get("three").Value);

                db.Del("one", "two", "three");

                Assert.IsNull(db.Get("one"));
                Assert.IsNull(db.Get("two"));
                Assert.IsNull(db.Get("three"));

            }

            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);
        }
开发者ID:richorama,项目名称:ra-db,代码行数:34,代码来源:DatabaseTests.cs

示例7: SimpleDatabaseTestWithPoco

        public void SimpleDatabaseTestWithPoco()
        {
            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);

            using (var db = new Database<TestClass>("testdb"))
            {
                db.Set("foo", new TestClass { Foo = "foo", Bar = 1337, Baz=true, Qux = Math.PI });
                Assert.IsNotNull(db.Get("foo"));
            }

            using (var db = new Database<TestClass>("testdb"))
            {
                var foo = db.Get("foo");
                Assert.AreEqual("foo", foo.Foo);
                Assert.AreEqual(1337, foo.Bar);
                Assert.IsTrue(foo.Baz);
                Assert.AreEqual(Math.PI, foo.Qux);
            }

            if (Directory.Exists("testdb")) Directory.Delete("testdb", true);
        }
开发者ID:richorama,项目名称:ra-db,代码行数:21,代码来源:DatabaseTests.cs

示例8: Load

 protected void Load()
 {
     using (Database db = new Database(  ))
     {
         StoredProcedure storedProcedure = new StoredProcedure( "GetUrlCache" );
         System.Data.SqlClient.SqlDataReader rs = db.Get( storedProcedure );
         LoadRS ( rs );
         rs.Close();
     }
 }
开发者ID:adampax,项目名称:UfXtract,代码行数:10,代码来源:UrlCache.cs

示例9: Update

 protected void Update()
 {
     using ( Database db = new Database( ))
     {
         StoredProcedure storedProcedure = new StoredProcedure( "UpdateUrlCache" );
         LoadSP( storedProcedure );
         storedProcedure.AddParam( "dtLastUpdated", DateTime.Now );
         db.Get( storedProcedure ).Close();
     }
 }
开发者ID:adampax,项目名称:UfXtract,代码行数:10,代码来源:UrlCache.cs

示例10: Delete

 protected void Delete()
 {
     using ( Database db = new Database( ))
     {
         StoredProcedure storedProcedure = new StoredProcedure( "DeleteUrlCache" );
         storedProcedure.AddParam( "liUrlCacheID", this.UrlCacheID );
         db.Get( storedProcedure ).Close();
     }
 }
开发者ID:adampax,项目名称:UfXtract,代码行数:9,代码来源:UrlCache.cs


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