熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#開源輕量級對象數據庫NDatabase介紹[3]

2022-06-13   來源: .NET編程 

  再看復雜的

  View Code

  var volleyball = new Sport(volleyball

  var player = new Player(julia DateTimeNow volleyball)

  var player = new Player(magdalena DateTimeNow volleyball)

  var player = new Player(jacek DateTimeNow volleyball)

  var player = new Player(michal DateTimeNow volleyball)

  var team = new Team(Krakow

  var team = new Team(Skawina

  teamAddPlayer(player

  teamAddPlayer(player

  teamAddPlayer(player

  teamAddPlayer(player

  var game = new Game(DateTimeNow volleyball team team

  using (var odb = OdbFactoryOpen(TutorialDbMinName))

  odbStore(game)

   再看看幾個簡單的查詢例子

  最簡單的注釋就免了都比較簡單

  using (var odb = OdbFactoryOpen(TutorialDbMinName))

  {

  var query = odbQuery<Player>()

  queryDescend(NameConstrain(juliaEqual()

  var players = queryExecute<Player>()

  ConsoleWriteLine(\nStep (Soda) Players with name julia

  foreach (var player in players)

  ConsoleWriteLine(\t{} player)

  AssertThat(players HasCountEqualTo())

  }

  看看這種LINQ的查詢方式

  using (var odb = OdbFactoryOpen(TutorialDbMinName))

  {

  var players = from player in odbAsQueryable<Player>()

  where playerNameEquals(julia

  select player;

  ConsoleWriteLine(\nStep (Linq) Players with name julia

  foreach (var player in players)

  ConsoleWriteLine(\t{} player)

  AssertThat(playersCount() IsEqualTo())

  }

  簡單的例子就寫這麼多吧實際的還有很多靈活的操作比如比較查詢還對表直接的關系等等如果有興趣適合你可以看後面的資源鏈接

  NDatabase資源

  開源網址

  https://ndatabasecodeplexcom/

  http://ndatabasewixcom/home#!overview/ch

  http://ndatabasenet/

[]  []  []  


From:http://tw.wingwit.com/Article/program/net/201311/16139.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.