public void get_all_subclasses_of_a_subclass() { var smurf = new Smurf { Ability = "Follow the herd" }; var papa = new PapaSmurf { Ability = "Lead" }; var brainy = new BrainySmurf { Ability = "Invent" }; theSession.Store(smurf, papa, brainy); theSession.SaveChanges(); theSession.Query <Smurf>().Count().ShouldBe(3); }
public void get_all_subclasses_of_a_subclass_with_where_with_camel_casing() { StoreOptions(_ => { _.Schema.For <ISmurf>() .AddSubClassHierarchy(typeof(Smurf), typeof(PapaSmurf), typeof(PapySmurf), typeof(IPapaSmurf), typeof(BrainySmurf)); // Alternatively, you can use the following: // _.Schema.For<ISmurf>().AddSubClassHierarchy(); // this, however, will use the assembly // of type ISmurf to get all its' subclasses/implementations. // In projects with many types, this approach will be undvisable. _.UseDefaultSerialization(EnumStorage.AsString, Casing.CamelCase); _.Connection(ConnectionSource.ConnectionString); _.AutoCreateSchemaObjects = AutoCreate.All; _.Schema.For <ISmurf>().GinIndexJsonData(); }); var smurf = new Smurf { Ability = "Follow the herd" }; var papa = new PapaSmurf { Ability = "Lead" }; var brainy = new BrainySmurf { Ability = "Invent" }; theSession.Store(smurf, papa, brainy); theSession.SaveChanges(); theSession.Query <PapaSmurf>().Count(s => s.Ability == "Invent").ShouldBe(1); }
public async Task get_all_subclasses_of_an_interface_and_instantiate_them_async() { var smurf = new Smurf { Ability = "Follow the herd" }; var papa = new PapaSmurf { Ability = "Lead" }; var papy = new PapySmurf { Ability = "Lead" }; var brainy = new BrainySmurf { Ability = "Invent" }; theSession.Store(smurf, papa, brainy, papy); await theSession.SaveChangesAsync(); var list = await theSession.Query <IPapaSmurf>().ToListAsync(); list.Count().ShouldBe(3); list.Count(s => s.Ability == "Invent").ShouldBe(1); }