当前位置: 首页>>代码示例>>C#>>正文


C# DocumentStore.AddMap方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:AndyStewart,项目名称:docsharp,代码行数:14,代码来源:DocumentStoreTests.cs

示例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);
            }
        }
开发者ID:AndyStewart,项目名称:docsharp,代码行数:15,代码来源:DocumentStoreTests.cs

示例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);
            }
        }
开发者ID:AndyStewart,项目名称:docsharp,代码行数:16,代码来源:DocumentStoreTests.cs

示例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);
            }
        }
开发者ID:AndyStewart,项目名称:docsharp,代码行数:21,代码来源:DocumentStoreTests.cs


注:本文中的DocumentStore.AddMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。