2
有沒有辦法在不定義模型類的情況下查詢ravendb?通常情況下,我們定義模型和問題,這樣的查詢:查詢ravendb而不定義模型類?
public class Site
{
public string Title { get; set; }
public string URL { get; set; }
public string Notes { get; set; }
}
var documentStore = new Raven.Client.Document.DocumentStore{Url = "http://localhost:8080" };
documentStore.Initialize();
using (var session = documentStore.OpenSession())
{
var sites = session.Query<Site>()
.Where(x => x.Title.StartsWith("CN")).ToList();
for (int i = 0; i < sites.Count; i++) {
MessageBox.Show(sites[i].Title + " - " + sites[i].URL);
}
}
但我可以查詢像我可以爲SQL服務器 - 無定義表結構,我可能甚至不知道?在上面的示例中,我需要聲明一個類Site
才能運行查詢:var sites = session.Query<Site>()
。我想運行這樣的session.Query<"Site">()
這是可能的嗎?我如何設置此功能?
試圖測試這個,但不知道查詢方法駐留在哪個程序集中。它顯示我爲未定義的方法,並且我擁有來自nuget的所有ravendb客戶端。 –
好的,知道它是在Lucene包中。 –
謝謝,它工作正常。 –