public StoreSchema ReadSchema(IStoreSchemaReaderParameters parameters) { var dr = parameters as EntityFrameworkStoreSchemaReaderParameters; if (dr == null) { throw new Exception($"EntityFrameworkStoreSchemaReader expects EntityFrameworkStoreSchemaReaderParameters."); } var schema = new StoreSchema { Definitions = new Dictionary <string, StoreDefinition>(), DbContextName = dr.DbContextType.FullName }; using (var db = GetDbContext(dr.DbContextType)) { var entities = db.Model.GetEntityTypes(); foreach (var entityMetadata in entities) { var def = new StoreDefinition { Properties = new Dictionary <string, StoreProperty>() }; def.Name = entityMetadata.ClrType.Name; schema.Definitions.Add(def.Name, def); var props = entityMetadata.GetProperties().ToList(); for (int i = 0; i < props.Count; i++) { var prop = props[i]; var storeProp = new StoreProperty { Name = prop.Name, Order = i, Type = GetTypeString(prop.ClrType), Pk = prop.IsPrimaryKey(), Fk = prop.IsForeignKey(), MaxLength = prop.GetMaxLength(), AutoIncrement = prop.ValueGenerated == ValueGenerated.OnAdd }; if (prop.IsForeignKey()) { var fks = prop.GetContainingForeignKeys(); storeProp.ForeignKeys = prop.GetContainingForeignKeys().Select(f => new StoreForeignKey { DefinitionName = f.PrincipalEntityType.ClrType.Name, PropertyName = f.PrincipalKey.Properties.First().Name, CompositePropertyNames = f.PrincipalKey.Properties.Select(p => p.Name).ToList() }).ToList(); } def.Properties.Add(storeProp.Name, storeProp); } } } return(schema); }
public void AddFromTable(StoreDefinition table) { var ft = new QueryFromTable(table); ft.Alias = GetDefaultAlias(ft); FromTables.Add(ft); RegenerateTableLinks(); _engine.SelectPropertiesFromNewTable(this, ft); }
public IEnumerable <IStore> CreateStoresWithInvalidSections(IEnumerable <IStoreItemAvailability> availabilities) { foreach (var av in availabilities.ToList()) { var def = new StoreDefinition { Id = av.StoreId, Sections = Enumerable.Empty <IStoreSection>() }; yield return(StoreFixture.Create(def)); } }
public IStore CreateStore(StoreId storeId, SectionId sectionId) { var sectionDef = StoreSectionDefinition.FromId(sectionId); var storeDef = new StoreDefinition { Id = storeId, Sections = StoreSectionFixture.CreateMany(sectionDef, 1) }; return(StoreFixture.CreateValid(storeDef)); }
public IStore CreateStore(IShoppingList shoppingList, SectionId sectionId) { var sectionDef = StoreSectionDefinition.FromId(sectionId); var section = StoreSectionFixture.Create(sectionDef); var storeDef = new StoreDefinition { Id = shoppingList.StoreId, Sections = section.ToMonoList() }; return(StoreFixture.CreateValid(storeDef)); }
public IStoreItem CreateValidFor(IShoppingList shoppingList) { var storeDefinition = StoreDefinition.FromId(shoppingList.StoreId); var store = storeFixture.Create(storeDefinition); var availabilities = storeItemAvailabilityFixture.CreateManyValidWith(store, 4); var definition = new StoreItemDefinition { Availabilities = availabilities }; return(CreateValid(definition)); }
public void RemapStore <T>() { var type = typeof(T); var name = DynamicDataStoreFactory.Instance.GetStoreNameForType(type); var storeDef = StoreDefinition.Get(name); if (storeDef == null || storeDef.ValidateAgainstMappings(type, false)) { return; } storeDef.Remap(type); storeDef.CommitChanges(); }
public IEnumerable <IStore> CreateValidStores(IEnumerable <IStoreItemAvailability> availabilities) { var availabilitiesList = availabilities.ToList(); foreach (var availability in availabilitiesList) { var section = StoreSectionFixture.Create(StoreSectionDefinition.FromId(availability.DefaultSectionId)); var def = new StoreDefinition { Id = availability.StoreId, Sections = section.ToMonoList() }; yield return(StoreFixture.CreateValid(def)); } }
public static StoreDefinition ToStoreDefinition(DesignSchema schema, DesignTable t) { var d = new StoreDefinition { Name = t.Name, Order = t.Order, Properties = new Dictionary <string, StoreProperty>() }; int i = 0; d.Properties = t.Columns.Where(c => !c.IsEmpty()).ToDictionary(c => c.Name, c => new StoreProperty { Name = c.Name, Type = c.Type, Pk = c.Pk, Fk = !string.IsNullOrWhiteSpace(c.Reference), Nullable = c.Nullable, AutoIncrement = c.Pk, ForeignKeys = GetForeignKeysForColumn(schema, t, c), Order = i++ }); return(d); }
public IEnumerable <StoreDefinition> GetAllStoresNamesAndMappings() { var storeDefinitions = StoreDefinition.GetAll(); return(storeDefinitions); }
public InMemoryDynamicDataStore(StoreDefinition storeDefinition) : base(storeDefinition) { name = storeDefinition.StoreName; }
public DesignQueryObject(StoreDefinition table) { IsSubQuery = false; Table = table; }