public virtual void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { foreach (HierarchyDef hierarchy in model.Hierarchies) { hierarchy.Schema = Schema; } }
private static void ApplyModelFixesForMySql(DomainModelDef model) { BuildLog.Info("Applying changes to Metadata-related types for MySQL"); // Fixing length of Assembly.Name field TypeDef type = model.Types.TryGetValue(typeof(Assembly)); FieldDef field; if (type != null && type.Fields.TryGetValue("Name", out field)) { field.Length = 255; } // Fixing length of Extension.Name field type = model.Types.TryGetValue(typeof(Extension)); if (type != null && type.Fields.TryGetValue("Name", out field)) { field.Length = 255; } // Removing index on Type.Name field type = model.Types.TryGetValue(typeof(Type)); if (type != null && type.Indexes.Count > 0) { var indexes = type.Indexes.Where(i => i.KeyFields.ContainsKey("Name")).ToList(); foreach (var index in indexes) { type.Indexes.Remove(index); } } }
public void OnDefinitionsBuilt(BuildingContext buildingContext, DomainModelDef model) { if (!IsEnabled) { return; } context = buildingContext; try { Console.WriteLine("-- Verifying model --"); VerifyDefinition(); Console.WriteLine("-- Redefining types --"); RedefineTypes(); Console.WriteLine("-- Verifying model --"); VerifyDefinition(); Console.WriteLine("-- Redefining fields --"); RedefineFields(); Console.WriteLine("-- Redefining indexes --"); RedefineIndexes(); Console.WriteLine("-- Verifying model --"); VerifyDefinition(); VerifyTypeCollection(); } finally { context = null; } }
public void OnDefinitionsBuilt(Building.BuildingContext context, DomainModelDef model) { var documentDef = model.Types[typeof(noFTModel.Document)]; var title = documentDef.Fields["Title"]; var documentBody = documentDef.Fields["DocumentBody"]; var titleIndex = documentDef.Fields.IndexOf(title); var documentBodyIndex = documentDef.Fields.IndexOf(documentBody); var oldFieldsMap = documentDef.Fields.ToArray(); documentDef.Fields.Clear(); oldFieldsMap[titleIndex] = documentBody; oldFieldsMap[documentBodyIndex] = title; foreach (var fieldDef in oldFieldsMap) { documentDef.Fields.Add(fieldDef); } var ftIndexDef = new FullTextIndexDef(documentDef); ftIndexDef.Fields.Add( new FullTextFieldDef("DocumentBody", false) { Configuration = "English", TypeFieldName = "Extension" }); ftIndexDef.Fields.Add(new FullTextFieldDef("Title", false) { Configuration = "English" }); model.FullTextIndexes.Add(ftIndexDef); }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { var stateField = model.Types[typeof(EntityWithState)].Fields["State"]; stateField.Name = "EntityWithState.State"; stateField.MappingName = "EntityWithState.State"; }
private void DefineFullTextIndex(DomainModelDef model) { var customerType = model.Types[typeof(Customer)]; var fieldsToDefineIndex = customerType.Fields .Where(f => f.Name.In("FirstName", "LastName")) .Select(f => new FullTextFieldDef(f.Name, true) { Configuration = "English" }); var index = new FullTextIndexDef(customerType); index.Fields.AddRange(fieldsToDefineIndex); model.FullTextIndexes.Add(index); var addressType = model.Types[typeof(Address)]; fieldsToDefineIndex = addressType.Fields .Where(f => f.Name.In("Country", "Region", "City", "Street")) .Select(f => new FullTextFieldDef(f.Name, true) { Configuration = "English" }); index = new FullTextIndexDef(addressType); index.Fields.AddRange(fieldsToDefineIndex); model.FullTextIndexes.Add(index); }
public override void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!IsEnabled) { return; } base.OnDefinitionsBuilt(context, model); }
public virtual void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!IsEnabled) { return; } TypeIdField = new KeyField(WellKnown.TypeIdFieldName); }
public override void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!IsEnabled) { return; } base.OnDefinitionsBuilt(context, model); foreach (HierarchyDef hierarchy in model.Hierarchies) { hierarchy.IncludeTypeId = true; } }
public void OnDefinitionsBuilt(Building.BuildingContext context, DomainModelDef model) { var documentDef = model.Types[typeof(noFTModel.Document)]; var ftIndexDef = new FullTextIndexDef(documentDef); ftIndexDef.Fields.Add( new FullTextFieldDef("DocumentBody", false) { Configuration = "English", TypeFieldName = "Extension" }); model.FullTextIndexes.Add(ftIndexDef); }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (StorageProviderInfo.Instance.Provider != StorageProvider.Oracle) { return; } var field = model.Types[nameof(TestEntity)].Fields[nameof(TestEntity.FDateTime)]; field.DefaultValue = FormatDate(new DateTime(2012, 12, 12)); field.DefaultSqlExpression = $"'{FormatDate(new DateTime(2013, 12, 13))}'"; }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { var provider = context.Configuration.ConnectionInfo.ConnectionString ?? context.Configuration.ConnectionInfo.ConnectionUrl.Protocol; if (provider != WellKnown.Provider.MySql) { return; } var typeDef = model.Types[typeof(X)]; var problemField = typeDef.Fields["FLongString"]; problemField.DefaultValue = null; }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!isEnabled || !model.Types.Contains("A")) { return; } var aType = model.Types["A"]; var bType = model.Types["B"]; var xField = aType.Fields["X"]; _ = aType.Fields.Remove(xField); _ = model.Types.Remove(bType); }
/// <inheritdoc/> public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { var builderConfiguration = context.BuilderConfiguration; if (builderConfiguration.Stage == UpgradeStage.Upgrading && builderConfiguration.RecycledDefinitions != null) { ProcessRecycledDefinitions(builderConfiguration, model); } if (context.Configuration.ConnectionInfo.Provider == WellKnown.Provider.MySql) { ApplyModelFixesForMySql(model); } }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!IsEnabled) { return; } if (!model.Types.Contains("X")) { return; } var xType = model.Types["X"]; var newField = new FieldDef(NewColumnType, context.Validator); newField.Name = "NewColumn"; xType.Fields.Add(newField); }
public override void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!IsEnabled) { return; } base.OnDefinitionsBuilt(context, model); foreach (HierarchyDef hierarchy in model.Hierarchies) { hierarchy.IncludeTypeId = false; if (hierarchy.KeyFields.Contains(TypeIdField)) { hierarchy.KeyFields.Remove(TypeIdField); } } }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!IsActive) { return; } if (!model.Types.Contains("Ancestor")) { return; } var type = model.Types["Ancestor"]; var newField = new FieldDef(typeof(int), context.Validator); newField.Name = "NewField"; type.Fields.Add(newField); }
private void DefineDynamicFields(DomainModelDef model) { var addressType = model.Types[typeof(Address)]; var region = addressType.DefineField("Region", typeof(string)); region.Length = 200; var customerType = model.Types[typeof(Customer)]; var commentField = customerType.DefineField("ManagerSpecialComment", typeof(string)); commentField.Length = 250; customerType.DefineField("OptionalAddress", typeof(Address)); var storeType = model.Types[typeof(Store)]; storeType.DefineField("Address", typeof(Address)); }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!isEnabled || !model.Types.Contains("X")) { return; } var xType = model.Types["X"]; var oldFieled = xType.Fields[ColumnName]; var newField = new FieldDef(ColumnType, context.Validator); newField.Length = ColumnLength; newField.Scale = ColumnScale; newField.Precision = ColumnPrecision; newField.Name = oldFieled.Name; if (ColumnNullable != null) { newField.IsNullable = ColumnNullable.Value; } _ = xType.Fields.Remove(oldFieled); xType.Fields.Add(newField); }
public void ValidateHierarchyRoot(DomainModelDef modelDef, TypeDef typeDef) { // Ensures that typeDef doesn't belong to another hierarchy TypeDef root = modelDef.FindRoot(typeDef); if (root != null && typeDef != root) { throw new DomainBuilderException( String.Format(Strings.ExTypeDefXIsAlreadyBelongsToHierarchyWithTheRootY, typeDef.UnderlyingType.GetFullName(), root.UnderlyingType.GetFullName())); } // Ensures that typeDef is not an ancestor of any other hierarchy root foreach (HierarchyDef hierarchy in modelDef.Hierarchies) { if (hierarchy.Root.UnderlyingType.IsSubclassOf(typeDef.UnderlyingType)) { throw new DomainBuilderException(string.Format( Strings.ExXDescendantIsAlreadyARootOfAnotherHierarchy, hierarchy.Root.UnderlyingType)); } } }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { if (!IsEnabled) { return; } TypeDef type; type = model.Types[typeof(A)]; Assert.IsFalse(context.ModelDef.FindRoot(type) == type); type = model.Types[typeof(AB)]; Assert.IsTrue(context.ModelDef.FindRoot(type) == type); type = model.Types[typeof(ABC)]; Assert.IsFalse(context.ModelDef.FindRoot(type) == type); type = model.Types[typeof(B)]; Assert.IsFalse(context.ModelDef.FindRoot(type) == type); type = model.Types[typeof(BC)]; Assert.IsTrue(context.ModelDef.FindRoot(type) == type); }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { var originalCount = context.Domain.Handlers.ProviderInfo.MaxQueryParameterCount; var maxcount = originalCount; if (maxcount > 1024) { maxcount = 1000; } var validFieldCount = maxcount - 1; var invalidFieldCount = validFieldCount + 10; var t = model.Types[typeof(ALotOfFieldsEntityValid)]; foreach (var fieldName in GetFieldNames(validFieldCount)) { _ = t.DefineField(fieldName, typeof(int)); } t = model.Types[typeof(ALotOfFieldsEntityInvalid)]; foreach (var fieldName in GetFieldNames(invalidFieldCount)) { _ = t.DefineField(fieldName, typeof(int)); } t = model.Types[typeof(ALotOfFieldsEntityVersionized)]; foreach (var fieldName in GetFieldNames(validFieldCount - 1)) { _ = t.DefineField(fieldName, typeof(int)); } // each entitity field count is valid // overall entity field count is valid var types = new TypeDef[] { model.Types[typeof(SeveralPersistActionsEntityValidA)], model.Types[typeof(SeveralPersistActionsEntityValidB)], model.Types[typeof(SeveralPersistActionsEntityValidC)], }; var indexToWrite = 0; var currentFieldCount = 0; foreach (var fieldName in GetFieldNames(validFieldCount)) { _ = types[indexToWrite].DefineField(fieldName, typeof(int)); currentFieldCount++; if (currentFieldCount > validFieldCount / 3) { indexToWrite = 1; } if (currentFieldCount > validFieldCount / 3 * 2) { indexToWrite = 2; } } // each entity field count should be valid // overall count should be invalid types = new TypeDef[] { model.Types[typeof(SeveralPersistActionsEntityInvalidA)], model.Types[typeof(SeveralPersistActionsEntityInvalidB)], model.Types[typeof(SeveralPersistActionsEntityInvalidC)], }; indexToWrite = 0; currentFieldCount = 0; var fieldsCount = 2100; foreach (var fieldName in GetFieldNames(fieldsCount)) { _ = types[indexToWrite].DefineField(fieldName, typeof(int)); currentFieldCount++; if (currentFieldCount > fieldsCount / 3) { indexToWrite = 1; } if (currentFieldCount > fieldsCount / 3 * 2) { indexToWrite = 2; } } }
private static void ProcessRecycledDefinitions(DomainBuilderConfiguration configuration, DomainModelDef model) { var fieldDefinitions = configuration.RecycledDefinitions.OfType <RecycledFieldDefinition>(); foreach (var definition in fieldDefinitions) { var entity = model.Types.TryGetValue(definition.OwnerType); if (entity == null) { throw new InvalidOperationException(string.Format( Strings.ExUnableToProcessRecycledFieldDefinitionXOwnerTypeIsNotRegisteredInModel, definition.OwnerType)); } entity.DefineField(definition.FieldName, definition.FieldType); } }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { DefineDynamicFields(model); DefineFullTextIndex(model); }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { var domain = context.Domain; domain.Extensions.Set(model); }
public void OnDefinitionsBuilt(BuildingContext context, DomainModelDef model) { }