再看復雜的
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(Name)Constrain(julia)Equal()
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