我使用RavenDB(NoSQL數據庫),我有這個類:存儲空值的實體在某些領域中RavenDB
public class VirtualDirectory
{
public string Id { get; set; }
public string HostAlias { get; set; }
public string VirtualPath { get; set; }
public string IdentificationMethod { get; set; }
public int IsCancelled { get; set; }
}
我通過啓動這個類的一個新實例:
VirtualDirectory vd = new VirtualDirectory() { HostAlias = "bla", IsCancelled = 0 };
而且通過保存文件:
using (var session = DbConnection.Instance.DocumentStore.OpenSession(DbName))
{
session.Store(vd);
session.SaveChanges();
}
從我所瞭解的NoSQL數據庫文件,該文件是不侷限於模式,所以它們的結構是靈活的。
我的問題是: 如何將數據保存到我的RavenDB數據庫,但沒有在未設置的字段中獲得空值?最後一段代碼後,我的數據庫是這樣的:
{
HostAlias : "bla",
VirtualPath : null,
IdentificationMethod : null,
IsCancelled : 0
}
當我得到一個C#對象(VirtualDirectory類型),缺少像一些領域:
{
HostAlias : "bla",
IsCancelled : 0
}
會是空值?
爲每個屬性的組合設置對象是沒有意義的。 – ohadinho 2013-05-06 11:39:44
ofc不是 - 我以爲你只是想要你指定的2個屬性作爲你的對象的子集 – JanivZ 2013-05-06 11:48:20