public async Task Initialize() { // Quickly create a new domain named 'test' with its schema MyModelDefinition var domain = await StoreBuilder.CreateDomain <LibraryDefinition>("lib"); // Allow to omit the domain argument when you create a domain element. domain.Store.DefaultSessionConfiguration.DefaultDomainModel = domain; // Instanciate a new Library within the domain (always in a session) var rnd = new Random(); using (var session = domain.Store.BeginSession()) { Library = new Library(); Library.Name = "My library"; for (int i = 1; i < 20; i++) { var b = new Book(); b.Title = "Book " + i.ToString(); b.Copies = 1 + rnd.Next(10); Library.Books.Add(b); var m = new Member(); m.Name = "Member " + i.ToString(); Library.Members.Add(m); } session.AcceptChanges(); } }
public async Task CheckPrimitives() { var domain = await StoreBuilder.CreateDomain <MySchemaDefinition>("Test"); var store = domain.Store; Assert.NotNull(store.GetSchemaInfo <string>()); Assert.NotNull(store.GetSchemaInfo <int>()); Assert.NotNull(store.GetSchemaInfo <double>()); }
public async Task UnloadPrimitivesSchemaMustFailed() { var domain = await StoreBuilder.CreateDomain <MySchemaDefinition>("Test"); var store = domain.Store; var schema = store.Schemas.All().First(s => s.Name != "hyperstore.xtests"); Assert.NotNull(schema); Assert.IsType <PrimitivesSchema>(schema); Assert.Throws <HyperstoreException>(() => store.Schemas.Unload(schema)); }
public async Task Initialize() { // Quickly create a new domain named 'test' with its schema MyModelDefinition var domain = await StoreBuilder.CreateDomain <MyModelDefinition>("test"); // Instanciate a new Customer within the domain (always in a session) using (var session = domain.Store.BeginSession()) { Customer = new Customer(domain); session.AcceptChanges(); } }