コード例 #1
0
ファイル: Spokey.cs プロジェクト: yitaom2/ravendb
        public void Can_project_InternalId_from_transformResults2()
        {
            var taxonomyCode1 = new TaxonomyCode
            {
                EffectiveFrom    = new DateTime(2011, 1, 1),
                EffectiveThrough = new DateTime(2011, 2, 1),
                InternalId       = "taxonomycodetests/1",
                Name             = "ANESTHESIOLOGY",
                Code             = "207L00000X",
            };
            var provider1 = new Provider1
            {
                Name            = "Joe Schmoe",
                TaxonomyCodeRef = new Reference
                {
                    InternalId = taxonomyCode1.InternalId,
                    Name       = taxonomyCode1.Name
                }
            };

            using (var store = GetDocumentStore(new Options
            {
                ModifyDocumentStore = s =>
                {
                    s.Conventions.FindIdentityProperty = (x => x.Name == "InternalId");
                }
            }))
            {
                using (var session = store.OpenSession())
                {
                    session.Store(taxonomyCode1);
                    session.Store(provider1);
                    session.SaveChanges();
                }

                new IdentityProjectionIndex1().Execute(store);

                using (var session = store.OpenSession())
                {
                    var result = session.Query <Provider1, IdentityProjectionIndex1>()
                                 .Customize(x => x.WaitForNonStaleResults())
                                 .Select(p => p)
                                 .First();

                    Assert.Equal(provider1.Name, result.Name);
                    Assert.Equal(provider1.InternalId, result.InternalId);
                }
            }
        }
コード例 #2
0
ファイル: Spokey.cs プロジェクト: dkardach/ravendb
        public void Can_project_InternalId_from_transformResults2()
        {
            var taxonomyCode1 = new TaxonomyCode
            {
                EffectiveFrom    = new DateTime(2011, 1, 1),
                EffectiveThrough = new DateTime(2011, 2, 1),
                InternalId       = "taxonomycodetests/1",
                Name             = "ANESTHESIOLOGY",
                Code             = "207L00000X",
            };
            var provider1 = new Provider1
            {
                Name            = "Joe Schmoe",
                TaxonomyCodeRef = new Reference
                {
                    InternalId = taxonomyCode1.InternalId,
                    Name       = taxonomyCode1.Name
                }
            };

            using (GetNewServer())
                using (var store = new DocumentStore {
                    Url = "http://localhost:8079"
                }.Initialize())
                {
                    store.Conventions.FindIdentityProperty = (x => x.Name == "InternalId");

                    using (var session = store.OpenSession())
                    {
                        session.Store(taxonomyCode1);
                        session.Store(provider1);
                        session.SaveChanges();
                    }

                    new IdentityProjectionIndex1().Execute(store);
                    new IdentityProjectionIndex1Transformer().Execute(store);

                    using (var session = store.OpenSession())
                    {
                        var result = (from p in session.Query <Provider1, IdentityProjectionIndex1>()
                                      .Customize(x => x.WaitForNonStaleResults()).TransformWith <IdentityProjectionIndex1Transformer, Provider1>()
                                      select p).First();
                        Assert.Equal(provider1.Name, result.Name);
                        Assert.Equal(provider1.InternalId, result.InternalId);
                    }
                }
        }
コード例 #3
0
        public void Can_reference_child_documents_in_index()
        {
            using (var store = GetDocumentStore())
            {
                new ProviderAndTaxonomyCodeIndex1().Execute(store);

                var taxonomyCode1 = new TaxonomyCode
                {
                    EffectiveFrom    = new DateTime(2011, 1, 1),
                    EffectiveThrough = new DateTime(2011, 2, 1),
                    InternalId       = "taxonomycodetests/1",
                    Name             = "ANESTHESIOLOGY",
                    Code             = "207L00000X",
                };
                var taxonomyCode2 = new TaxonomyCode
                {
                    EffectiveFrom    = new DateTime(2011, 2, 1),
                    EffectiveThrough = new DateTime(2011, 3, 1),
                    InternalId       = "taxonomycodetests/2",
                    Name             = "FAMILY PRACTICE",
                    Code             = "207Q00000X",
                };
                var provider1 = new Provider1
                {
                    Name            = "Joe Schmoe",
                    TaxonomyCodeRef = new Reference
                    {
                        InternalId = taxonomyCode1.InternalId,
                        Name       = taxonomyCode1.Name
                    }
                };

                using (var session = store.OpenSession())
                {
                    session.Store(taxonomyCode1);
                    session.Store(taxonomyCode2);
                    session.Store(provider1);
                    session.SaveChanges();
                }

                WaitForIndexing(store);

                using (var session = store.OpenSession())
                {
                    var result =
                        (from p in session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                         where p.Name == provider1.Name
                         select p).FirstOrDefault();
                    Assert.NotNull(result);
                    Assert.Equal(provider1.Name, result.Name);
                }
                using (var session = store.OpenSession())
                {
                    var result =
                        (from p in session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                         where p.TaxonomyCode_EffectiveFrom == taxonomyCode1.EffectiveFrom
                         select p).FirstOrDefault();
                    Assert.NotNull(result);
                    Assert.Equal(taxonomyCode1.EffectiveFrom, result.TaxonomyCode_EffectiveFrom);
                }
            }
        }
コード例 #4
0
        public void CanReferenceChildDocumentsInIndex()
        {
            using (GetNewServer())
                using (var store = new DocumentStore {
                    Url = "http://localhost:8079"
                }.Initialize())
                {
                    store.Conventions.FindIdentityProperty = (x => x.Name == "InternalId");
                    new ProviderAndTaxonomyCodeIndex1().Execute(store);

                    var taxonomyCode1 = new TaxonomyCode
                    {
                        EffectiveFrom    = new DateTime(2011, 1, 1),
                        EffectiveThrough = new DateTime(2011, 2, 1),
                        InternalId       = "taxonomycodetests/1",
                        Name             = "ANESTHESIOLOGY",
                        Code             = "207L00000X",
                    };
                    var taxonomyCode2 = new TaxonomyCode
                    {
                        EffectiveFrom    = new DateTime(2011, 2, 1),
                        EffectiveThrough = new DateTime(2011, 3, 1),
                        InternalId       = "taxonomycodetests/2",
                        Name             = "FAMILY PRACTICE",
                        Code             = "207Q00000X",
                    };
                    var provider1 = new Provider1
                    {
                        Name            = "Joe Schmoe",
                        TaxonomyCodeRef = new Reference
                        {
                            InternalId = taxonomyCode1.InternalId,
                            Name       = taxonomyCode1.Name
                        }
                    };

                    using (var session = store.OpenSession())
                    {
                        session.Store(taxonomyCode1);
                        session.Store(taxonomyCode2);
                        session.Store(provider1);
                        session.SaveChanges();
                    }

                    using (var session = store.OpenSession())
                    {
                        var result = session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                                     .Customize(x => x.WaitForNonStaleResults())
                                     .FirstOrDefault(p => p.Name == provider1.Name);

                        var serverErrors = store.DatabaseCommands.GetStatistics().Errors;
                        try
                        {
                            Assert.Empty(serverErrors);
                        }
                        catch (Exception)
                        {
                            serverErrors.ForEach(Console.WriteLine);
                            throw;
                        }

                        Assert.NotNull(result);
                        Assert.Equal(provider1.Name, result.Name);
                    }

                    using (var session = store.OpenSession())
                    {
                        var result = session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                                     .FirstOrDefault(p => p.TaxonomyCode_EffectiveFrom == taxonomyCode1.EffectiveFrom);
                        Assert.NotNull(result);
                        Assert.Equal(taxonomyCode1.EffectiveFrom, result.TaxonomyCode_EffectiveFrom);
                    }
                }
        }
コード例 #5
0
        public void CanReferenceChildDocumentsInIndex()
        {
            using (var store = GetDocumentStore(new Options
            {
                ModifyDocumentStore = s =>
                {
                    s.Conventions.FindIdentityProperty = (x => x.Name == "InternalId");
                }
            }))
            {
                new ProviderAndTaxonomyCodeIndex1().Execute(store);

                var taxonomyCode1 = new TaxonomyCode
                {
                    EffectiveFrom    = new DateTime(2011, 1, 1),
                    EffectiveThrough = new DateTime(2011, 2, 1),
                    InternalId       = "taxonomycodetests/1",
                    Name             = "ANESTHESIOLOGY",
                    Code             = "207L00000X",
                };
                var taxonomyCode2 = new TaxonomyCode
                {
                    EffectiveFrom    = new DateTime(2011, 2, 1),
                    EffectiveThrough = new DateTime(2011, 3, 1),
                    InternalId       = "taxonomycodetests/2",
                    Name             = "FAMILY PRACTICE",
                    Code             = "207Q00000X",
                };
                var provider1 = new Provider1
                {
                    Name            = "Joe Schmoe",
                    TaxonomyCodeRef = new Reference
                    {
                        InternalId = taxonomyCode1.InternalId,
                        Name       = taxonomyCode1.Name
                    }
                };

                using (var session = store.OpenSession())
                {
                    session.Store(taxonomyCode1);
                    session.Store(taxonomyCode2);
                    session.Store(provider1);
                    session.SaveChanges();
                }

                using (var session = store.OpenSession())
                {
                    var result = session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                                 .Customize(x => x.WaitForNonStaleResults())
                                 .FirstOrDefault(p => p.Name == provider1.Name);

                    RavenTestHelper.AssertNoIndexErrors(store);

                    Assert.NotNull(result);
                    Assert.Equal(provider1.Name, result.Name);
                }

                using (var session = store.OpenSession())
                {
                    var result = session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                                 .FirstOrDefault(p => p.TaxonomyCode_EffectiveFrom == taxonomyCode1.EffectiveFrom);
                    Assert.NotNull(result);
                    Assert.Equal(taxonomyCode1.EffectiveFrom, result.TaxonomyCode_EffectiveFrom);
                }
            }
        }
コード例 #6
0
ファイル: Spokey5.cs プロジェクト: yogiramchandani/ravendb
        public void Can_reference_child_documents_in_index()
        {
            using (GetNewServer())
                using (var store = new DocumentStore {
                    Url = "http://localhost:8079"
                })
                {
                    store.Initialize();
                    store.Conventions.FindIdentityProperty = (x => x.Name == "InternalId");
                    new ProviderAndTaxonomyCodeIndex1().Execute(store);

                    var taxonomyCode1 = new TaxonomyCode
                    {
                        EffectiveFrom    = new DateTime(2011, 1, 1),
                        EffectiveThrough = new DateTime(2011, 2, 1),
                        InternalId       = "taxonomycodetests/1",
                        Name             = "ANESTHESIOLOGY",
                        Code             = "207L00000X",
                    };
                    var taxonomyCode2 = new TaxonomyCode
                    {
                        EffectiveFrom    = new DateTime(2011, 2, 1),
                        EffectiveThrough = new DateTime(2011, 3, 1),
                        InternalId       = "taxonomycodetests/2",
                        Name             = "FAMILY PRACTICE",
                        Code             = "207Q00000X",
                    };
                    var provider1 = new Provider1
                    {
                        Name            = "Joe Schmoe",
                        TaxonomyCodeRef = new Reference
                        {
                            InternalId = taxonomyCode1.InternalId,
                            Name       = taxonomyCode1.Name
                        }
                    };

                    using (var session = store.OpenSession())
                    {
                        session.Store(taxonomyCode1);
                        session.Store(taxonomyCode2);
                        session.Store(provider1);
                        session.SaveChanges();
                    }

                    using (var session = store.OpenSession())
                    {
                        var result =
                            (from p in session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                             .Customize(x => x.WaitForNonStaleResults())
                             where p.Name == provider1.Name
                             select p).FirstOrDefault();
                        Assert.NotNull(result);
                        Assert.Equal(provider1.Name, result.Name);
                    }
                    using (var session = store.OpenSession())
                    {
                        var result =
                            (from p in session.Query <ProviderAndTaxonomyCodeIndex1.ProviderTestDto, ProviderAndTaxonomyCodeIndex1>()
                             where p.TaxonomyCode_EffectiveFrom == taxonomyCode1.EffectiveFrom
                             select p).FirstOrDefault();
                        Assert.NotNull(result);
                        Assert.Equal(taxonomyCode1.EffectiveFrom, result.TaxonomyCode_EffectiveFrom);
                    }
                }
        }