本文整理汇总了C#中DocumentStore.AddMap方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentStore.AddMap方法的具体用法?C# DocumentStore.AddMap怎么用?C# DocumentStore.AddMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentStore
的用法示例。
在下文中一共展示了DocumentStore.AddMap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_map_Entity_Id_to_document_during_store
public void Should_map_Entity_Id_to_document_during_store()
{
using (var documentStore = new DocumentStore())
{
documentStore.Database = DbName;
documentStore.AddMap(new CompanyMap());
documentStore.Initialise();
var session = documentStore.OpenSession();
var company = new Company() { Name = "Company 1" };
session.Store(company);
Assert.AreNotEqual(Guid.Empty, company.Id);
}
}
示例2: Should_Load_entity_back_with_document_Id_mapped_to_Id
public void Should_Load_entity_back_with_document_Id_mapped_to_Id()
{
using (var documentStore = new DocumentStore())
{
documentStore.Database = DbName;
documentStore.AddMap(new CompanyMap());
documentStore.Initialise();
var documentId = documentStore.DocSharp.Store(new Company { Name = "Company NAme" });
var session = documentStore.OpenSession();
var companyFound = session.Load<Company>(documentId.Id);
Assert.AreEqual(companyFound.Id, documentId.Id);
}
}
示例3: Should_update_stored_entity
public void Should_update_stored_entity()
{
using (var documentStore = new DocumentStore())
{
documentStore.Database = DbName;
documentStore.AddMap(new CompanyMap());
documentStore.Initialise();
var session = documentStore.OpenSession();
var company = new Company { Name = "Company 1" };
session.Store(company);
company.Name = "Company 2";
session.SaveChanges();
Assert.AreEqual("Company 2", session.Load<Company>(company.Id).Name);
}
}
示例4: Should_update_retrieved_entity
public void Should_update_retrieved_entity()
{
using (var documentStore = new DocumentStore())
{
documentStore.Database = DbName;
documentStore.AddMap(new CompanyMap());
documentStore.Initialise();
var session1 = documentStore.OpenSession();
var company = new Company {Name = "Company 1"};
session1.Store(company);
var companyId = company.Id;
var session2 = documentStore.OpenSession();
var companyFound = session2.Load<Company>(companyId);
companyFound.Name = "New Name";
session2.SaveChanges();
Assert.AreEqual("New Name", session2.Load<Company>(companyId).Name);
}
}