我正在尝试创建一个简单的参考,但我没有得到它。成功创建了“customers”集合,但未创建“orders”集合。
这段代码有什么问题?
public static void Main()
{
var mapper = BsonMapper.Global;
mapper.Entity<Customer>()
.DbRef(x => x.Order, "orders");
using (var db = new LiteDatabase(@"MyData.db", mapper))
{
var col = db.GetCollection<Customer>("customers");
var customer = new Customer
{
Id = 1,
Name = "John Doe",
Phones = new string[] { "8000-0000", "9000-0000" },
Age = 39,
IsActive = true,
Order = new Order { Id = 1, Name = "My first order" }
};
col.Insert(customer);
}
}