/// <summary> /// Constructor which contains default settings. /// </summary> public UserSettings() { Namespace = ""; DbContextName = "MyDb"; ConnectionStringName = ""; // Searches for this connection string in config files listed below ConfigurationClassName = "Configuration"; // Configuration, Mapping, Map, etc. This is appended to the Poco class name to configure the mappings. ConfigFilenameSearchOrder = new string[] { "app.config", "web.config", "app.config.transform", "web.config.transform" }; // Add more here if required. The config files are searched for in the local project first, then the whole solution second. MakeClassesPartial = false; GenerateSeparateFiles = false; UseCamelCase = true; // This will rename the tables & fields to use CamelCase. If false table & field names will be left alone. IncludeComments = true; // Adds comments the generated code IncludeViews = true; DisableGeographyTypes = false; // Turns off use of System.Data.Entity.Spatial.DbGeography and System.Data.Entity.Spatial.DbGeometry as OData doesn't support entities with geometry/geography types. CollectionType = "List"; // Determines the type of collection for the Navigation Properties. "ObservableCollection" for example CollectionTypeNamespace = ""; EntityNameService = new EntityNameService(EntityNameService.EN); ElementsToGenerate = Elements.Poco; PocoNamespace = ""; ContextNamespace = ""; UnitOfWorkNamespace = ""; PocoConfigurationNamespace = ""; SchemaName = null; PrependSchemaName = true; WritePocoClassAttributes = t => { // Do nothing by default // Example: // if(t.ClassName.StartsWith("Order")) // WriteLine(" [SomeAttribute]"); }; WritePocoBaseClasses = null; WritePocoBaseClassBody = t => { // Do nothing by default // Example: // WriteLine(" // " + t.ClassName); }; WritePocoColumn = c => c.Entity; }
public ColumnWrapper(DatabaseColumn column, TableWrapper tableWrapper, UserSettings settings) { var nameHelper = settings.EntityNameService; var useCamelCase = settings.UseCamelCase; var prependSchemaName = settings.PrependSchemaName; _column = column; //string typename = rdr["TypeName"].ToString().Trim(); //var col = new Column //{ // Name = rdr["ColumnName"].ToString().Trim(), // PropertyType = GetPropertyType(typename), // MaxLength = (int)rdr["MaxLength"], // Precision = (int)rdr["Precision"], // Default = rdr["Default"].ToString().Trim(), // DateTimePrecision = (int)rdr["DateTimePrecision"], // Scale = (int)rdr["Scale"], // Ordinal = (int)rdr["Ordinal"], // IsIdentity = rdr["IsIdentity"].ToString().Trim().ToLower() == "true", // IsNullable = rdr["IsNullable"].ToString().Trim().ToLower() == "true", // IsStoreGenerated = rdr["IsStoreGenerated"].ToString().Trim().ToLower() == "true", // IsPrimaryKey = rdr["PrimaryKey"].ToString().Trim().ToLower() == "true" //}; //col.IsRowVersion = col.IsStoreGenerated && !col.IsNullable && typename == "timestamp"; //if (col.IsRowVersion) // col.MaxLength = 8; //col.CleanUpDefault(); PropertyName = EntityNameService.CleanUp(Name); PropertyName = RxClean.Replace(PropertyName, "_$1"); //// Make sure property name doesn't clash with class name if (PropertyName == tableWrapper.NameHumanCase) { PropertyName = PropertyName + "_"; } PropertyNameHumanCase = (useCamelCase ? nameHelper.ToTitleCase(PropertyName) : PropertyName).Replace(" ", ""); if (PropertyNameHumanCase == string.Empty) { PropertyNameHumanCase = PropertyName; } // Make sure property name doesn't clash with class name if (PropertyNameHumanCase == tableWrapper.NameHumanCase) { PropertyNameHumanCase = PropertyNameHumanCase + "_"; } if (char.IsDigit(PropertyNameHumanCase[0])) { PropertyNameHumanCase = "_" + PropertyNameHumanCase; } //if (CheckNullable(col) != string.Empty) // table.HasNullableColumns = true; // If PropertyType is empty, return null. Most likely ignoring a column due to legacy (such as OData not supporting spatial types) if (string.IsNullOrEmpty(PropertyType)) { throw new InvalidOperationException(string.Format("Unable to create Helper for column {0}", _column.Name)); } }