├── .nuget ├── NuGet.exe └── NuGet.Config ├── SalarDbCodeGenerator.Tests ├── Test References │ └── SalarDbCodeGenerator.accessor ├── Properties │ └── AssemblyInfo.cs └── GenerationTestBase.cs ├── SalarDbCodeGenerator ├── Patterns │ ├── Thumbs.db │ ├── SampleDbDiagram.png │ ├── 3Tier VB.NET │ │ ├── Enumerations.patml │ │ ├── AppConfig.patml │ │ ├── TableModel.User.patml │ │ ├── TableBLL.User.patml │ │ ├── TableDAL.User.patml │ │ ├── DbConnection.patml │ │ ├── BLLBase.patml │ │ ├── ModelBase.patml │ │ ├── DALBase.patml │ │ ├── DbTransaction.patml │ │ ├── VS2010ClassProject.patml │ │ ├── VS2008ClassProject.patml │ │ └── TableBLL.Principal.patml │ ├── 3Tier C# │ │ ├── Enumerations.patml │ │ ├── AppConfig.patml │ │ ├── TableBLL.User.patml │ │ ├── TableModel.User.patml │ │ ├── TableDAL.User.patml │ │ ├── DbConnection.patml │ │ ├── BLLBase.patml │ │ ├── ModelBase.patml │ │ ├── DALBase.patml │ │ ├── DbTransaction.patml │ │ ├── VS2010ClassProject.patml │ │ └── VS2008ClassProject.patml │ ├── LinqToSql C# │ │ ├── Enumerations.patml │ │ ├── AppConfig.patml │ │ ├── ViewBaseBLL.patml │ │ ├── DbConnection.patml │ │ ├── TableBLL.User.patml │ │ ├── ViewBLL.User.patml │ │ ├── TableEntity.User.patml │ │ ├── DbTransaction.patml │ │ ├── BaseEntity.patml │ │ ├── TableBaseBLL.patml │ │ ├── BLLBase.patml │ │ ├── ViewBLL.Principal.patml │ │ ├── VS2010ClassProject.patml │ │ ├── VS2008ClassProject.patml │ │ └── TableBLL.Principal.patml │ ├── EF4 POCO C# │ │ ├── AppConfig.patml │ │ ├── Entity.User.patml │ │ ├── BaseEntity.patml │ │ ├── EntityObjectContext.patml │ │ └── VS2010ClassProject.patml │ ├── DapperAccess │ │ ├── AppConfig.patml │ │ ├── DapperEntityUser.patml │ │ ├── DapperAccessUser.patml │ │ ├── BaseModel.patml │ │ └── VS2010ClassProject.patml │ ├── DapperContext │ │ ├── AppConfig.patml │ │ ├── DapperEntityUser.patml │ │ ├── DapperContextUser.patml │ │ ├── BaseModel.patml │ │ ├── DapperDbConnection.patml │ │ ├── DapperConnectionContainer.patml │ │ ├── DapperModelQuery.patml │ │ ├── DapperContext.patml │ │ └── VS2010ClassProject.patml │ ├── DapperSQLinq │ │ ├── AppConfig.patml │ │ ├── DapperEntityUser.patml │ │ ├── DapperAccessUser.patml │ │ ├── BaseModel.patml │ │ ├── DapperDynamicParameters.patml │ │ └── VS2010ClassProject.patml │ ├── EF4 POCO LINQ C# │ │ ├── AppConfig.patml │ │ ├── EntityBLL.User.patml │ │ ├── DbConnection.patml │ │ ├── Entity.User.patml │ │ ├── DbTransaction.patml │ │ ├── BaseEntity.patml │ │ ├── EntityObjectContext.patml │ │ ├── BLLBase.patml │ │ └── VS2010ClassProject.patml │ ├── NHibernate MapByCode │ │ ├── AppConfig.patml │ │ ├── Entity.User.patml │ │ ├── DbMapper.User.patml │ │ └── Entity.DataAnnotations.patml │ ├── NHibernate MapByCode MVVM │ │ ├── AppConfig.patml │ │ ├── Entity.User.patml │ │ ├── DbMapper.User.patml │ │ └── Entity.DataAnnotations.patml │ ├── NHibernate MapByCode Simple │ │ ├── AppConfig.patml │ │ ├── Entity.User.patml │ │ └── DbMapper.User.patml │ ├── NHibernate ActiveRecord WCF │ │ ├── Entity.User.patml │ │ ├── ActiveRecordConfig.patml │ │ └── ActiveRecord.patml │ └── NHibernate ActiveRecord │ │ ├── Entity.User.patml │ │ ├── ActiveRecordConfig.patml │ │ └── ActiveRecord.patml ├── Resources │ ├── Add16.png │ ├── AppRes.res │ ├── Exit16.png │ ├── New16.png │ ├── Open16.gif │ ├── Save16.png │ ├── About16.png │ ├── AppIcon.ico │ ├── Delete16.png │ ├── SaveAs16.png │ ├── ToLeft10.png │ ├── AppIcon128.png │ ├── DbRefetch16.png │ ├── Generate16.png │ ├── Refresh16.png │ ├── Settings16.png │ ├── ToRight10.png │ ├── DBPattern.dbpat.ico │ ├── DBProject.dbgen.ico │ └── DBPatternML.patml.ico ├── References │ ├── Npgsql.dll │ ├── SQLinq.dll │ ├── MySql.Data.dll │ ├── NHibernate.dll │ ├── EntityFramework.dll │ ├── Mono.Security.dll │ ├── Iesi.Collections.dll │ ├── Oracle.DataAccess.dll │ ├── policy.2.0.Npgsql.dll │ ├── System.Data.SQLite.dll │ ├── ICSharpCode.TextEditor.dll │ ├── System.Data.SQLite.Linq.dll │ ├── System.Data.SqlServerCe.dll │ └── policy.2.0.Npgsql.config ├── Properties │ ├── Settings.settings │ ├── Settings.Designer.cs │ └── AssemblyInfo.cs ├── Schema │ ├── DbSchemaReaders │ │ ├── DbSchemaNames.cs │ │ ├── Definations.cs │ │ ├── OracleQueries.txt │ │ └── ExSchemaEngine.cs │ ├── Database │ │ ├── DbForeignKeyAction.cs │ │ ├── DbView.cs │ │ ├── DbDatabase.cs │ │ ├── DbConstraintKey.cs │ │ ├── DbForeignKey.cs │ │ └── DbColumn.cs │ ├── Patterns │ │ ├── SchemaPatternBase.cs │ │ ├── ConditionItem.cs │ │ ├── PatternContent.cs │ │ ├── PatternLngSettings.cs │ │ └── PatternProject.cs │ └── DotNetSchemaDataInfo.cs ├── packages.config ├── RegionHelper.cs ├── DbProject │ ├── ProjectRenaming.cs │ ├── ProjectCodeGenSettings.cs │ └── ProjectDefinaton.cs ├── Presentation │ ├── frmBase.cs │ └── frmAbout.cs ├── app.config ├── Program.cs └── ReleaseNotes.txt ├── .gitignore ├── Local.testsettings ├── SalarDbCodeGenerator.vsmdi ├── Readme.txt ├── TraceAndTestImpact.testsettings └── SalarDbCodeGenerator.sln /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/.nuget/NuGet.exe -------------------------------------------------------------------------------- /SalarDbCodeGenerator.Tests/Test References/SalarDbCodeGenerator.accessor: -------------------------------------------------------------------------------- 1 | SalarDbCodeGenerator.exe 2 | Desktop 3 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Patterns/Thumbs.db -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Add16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Add16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/AppRes.res: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/AppRes.res -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Exit16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Exit16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/New16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/New16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Open16.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Open16.gif -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Save16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Save16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/Npgsql.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/Npgsql.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/SQLinq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/SQLinq.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/About16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/About16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/AppIcon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/AppIcon.ico -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Delete16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Delete16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/SaveAs16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/SaveAs16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/ToLeft10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/ToLeft10.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/MySql.Data.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/MySql.Data.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/NHibernate.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/NHibernate.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/AppIcon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/AppIcon128.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/DbRefetch16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/DbRefetch16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Generate16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Generate16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Refresh16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Refresh16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/Settings16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/Settings16.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/ToRight10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/ToRight10.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/SampleDbDiagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Patterns/SampleDbDiagram.png -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/EntityFramework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/EntityFramework.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/Mono.Security.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/Mono.Security.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/DBPattern.dbpat.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/DBPattern.dbpat.ico -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/DBProject.dbgen.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/DBProject.dbgen.ico -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/Iesi.Collections.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/Iesi.Collections.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/Oracle.DataAccess.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/Oracle.DataAccess.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/policy.2.0.Npgsql.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/policy.2.0.Npgsql.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Resources/DBPatternML.patml.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/Resources/DBPatternML.patml.ico -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/System.Data.SQLite.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/System.Data.SQLite.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/ICSharpCode.TextEditor.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/ICSharpCode.TextEditor.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/System.Data.SQLite.Linq.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/System.Data.SQLite.Linq.dll -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/System.Data.SqlServerCe.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/salarcode/SalarDbCodeGenerator/HEAD/SalarDbCodeGenerator/References/System.Data.SqlServerCe.dll -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.csproj.user 3 | *.ncb 4 | *.aps 5 | *.suo 6 | /SalarDbCodeGenerator/bin 7 | /SalarDbCodeGenerator/obj 8 | /SalarDbCodeGenerator.Tests/bin 9 | /SalarDbCodeGenerator.Tests/obj 10 | /SampleGenProjects 11 | /SampleDB 12 | /_ReSharper.SalarDbCodeGenerator 13 | /!Releases -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/DbSchemaReaders/DbSchemaNames.cs: -------------------------------------------------------------------------------- 1 | 2 | namespace SalarDbCodeGenerator.Schema.DbSchemaReaders 3 | { 4 | public class DbSchemaNames 5 | { 6 | public static string FieldName_RemoveInvalidChars(string name) 7 | { 8 | if (string.IsNullOrEmpty(name)) 9 | return name; 10 | return name.Replace(' ', '_').Replace('.', '_'); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Database/DbForeignKeyAction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SalarDbCodeGenerator.Schema.Database 7 | { 8 | public enum DbForeignKeyAction 9 | { 10 | /// 11 | /// Not specified in database 12 | /// 13 | NotSet = -1, 14 | NoAction = 0, 15 | Cascade, 16 | SetNull, 17 | SetDefault, 18 | Restrict 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Local.testsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | These are default test settings for a local test run. 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/Enumerations.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Enumerations 4 | Enumerations 5 | 12 | 13 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator.vsmdi: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/References/policy.2.0.Npgsql.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/Enumerations.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Enumerations 4 | Enumerations 5 | 12 | 13 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/Enumerations.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Enumerations 4 | Enumerations 5 | 12 | 13 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO C#/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperAccess/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperSQLinq/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | 22 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode MVVM/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode Simple/AppConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | AppConfig 4 | Application config file 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ]]> 20 | 21 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/TableModel.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Model 4 | Business model user custom methods pattern 5 | 12 | 13 | 19 | REM User custom methods for [:TableNameDb:] 20 | REM 21 | Partial Public Class [:TableName:]Model 22 | 23 | End Class 24 | End Namespace 25 | ]]> 26 | 27 | 28 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/TableBLL.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User BLL 4 | Busines logic layer user custom methods pattern 5 | 12 | 13 | 21 | REM User custom methods for [:TableNameDb:] 22 | REM 23 | Partial Public Class [:TableName:]BLL 24 | 25 | 26 | End Class 27 | End Namespace 28 | ]]> 29 | 30 | 31 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/EntityBLL.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/ViewBaseBLL.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ViewBaseBLL 4 | View base pattern 5 | 12 | 13 | : BLLBase where T : class 25 | { 26 | } 27 | } 28 | ]]> 29 | 30 | 31 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperAccess/DapperEntityUser.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 20 | /// User custom methods for [:TableName:] 21 | /// 22 | partial class [:TableName:] 23 | { 24 | 25 | } 26 | } 27 | ]]> 28 | 29 | 30 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/DapperEntityUser.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 20 | /// User custom methods for [:TableName:] 21 | /// 22 | partial class [:TableName:] 23 | { 24 | 25 | } 26 | } 27 | ]]> 28 | 29 | 30 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperSQLinq/DapperEntityUser.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 20 | /// User custom methods for [:TableName:] 21 | /// 22 | partial class [:TableName:] 23 | { 24 | 25 | } 26 | } 27 | ]]> 28 | 29 | 30 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/DbConnection.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbConnection 4 | Database connection provider pattern 5 | 12 | 13 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/TableBLL.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User BLL 4 | Busines logic layer for tables user custom methods 5 | 12 | 13 | 22 | /// User custom methods for [:TableNameDb:] 23 | /// 24 | partial class [:TableName:]BLL 25 | { 26 | 27 | } 28 | } 29 | ]]> 30 | 31 | 32 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/RegionHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | // ==================================== 7 | // SalarDbCodeGenerator 8 | // http://SalarDbCodeGenerator.codeplex.com 9 | // Salar Khalilzadeh 10 | // © 2012, All rights reserved 11 | // 2009-9-30 12 | // ==================================== 13 | namespace SalarDbCodeGenerator 14 | { 15 | class RegionHelper 16 | { 17 | #region local variables 18 | #endregion 19 | 20 | #region field variables 21 | #endregion 22 | 23 | #region properties 24 | #endregion 25 | 26 | #region public methods 27 | #endregion 28 | 29 | #region protected methods 30 | #endregion 31 | 32 | #region private methods 33 | #endregion 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/ViewBLL.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User View BLL 4 | Busines logic layer for views user custom methods 5 | 12 | 13 | 22 | /// User custom methods for [:TableNameDb:] 23 | /// 24 | partial class [:TableName:]BLL 25 | { 26 | 27 | } 28 | } 29 | ]]> 30 | 31 | 32 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/DbSchemaReaders/Definations.cs: -------------------------------------------------------------------------------- 1 | // ==================================== 2 | // SalarDbCodeGenerator 3 | // http://SalarDbCodeGenerator.codeplex.com 4 | // Salar Khalilzadeh 5 | // © 2012, All rights reserved 6 | // 2012/07/06 7 | // ==================================== 8 | namespace SalarDbCodeGenerator.Schema.DbSchemaReaders 9 | { 10 | public enum DatabaseProvider 11 | { 12 | SQLServer, 13 | SqlCe4, 14 | Oracle, 15 | SQLite, 16 | Npgsql, 17 | MySql 18 | } 19 | 20 | public enum DataProviderClassNames 21 | { 22 | ClassPrefix, 23 | ClassCommand, 24 | ClassConnection, 25 | ClassDataAdapter, 26 | ClassDataReader, 27 | ClassParameter, 28 | ClassTransaction, 29 | ClassNamespace, 30 | AssemblyReference, 31 | StoredProcParamPrefix 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/TableDAL.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User DAL 4 | Data access layer user custom methods pattern 5 | 12 | 13 | 22 | REM User custom methods for [:TableNameDb:] 23 | REM 24 | Partial Public Class [:TableName:]DAL 25 | 26 | 27 | End Class 28 | End Namespace 29 | ]]> 30 | 31 | 32 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/TableBLL.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User BLL 4 | Busines logic layer user custom methods pattern 5 | 12 | 13 | 23 | /// User custom methods for [:TableNameDb:] 24 | /// 25 | partial class [:TableName:]BLL 26 | { 27 | 28 | } 29 | } 30 | ]]> 31 | 32 | 33 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/TableModel.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Model 4 | Business model user custom methods pattern 5 | 12 | 13 | 23 | /// User custom methods for [:TableNameDb:] 24 | /// 25 | partial class [:TableName:]Model 26 | { 27 | 28 | } 29 | } 30 | ]]> 31 | 32 | 33 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/DbConnection.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbConnection 4 | Database connection provider pattern 5 | 12 | 13 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Database/DbView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | // ==================================== 7 | // SalarDbCodeGenerator 8 | // http://SalarDbCodeGenerator.codeplex.com 9 | // Salar Khalilzadeh 10 | // © 2012, All rights reserved 11 | // 2012/07/06 12 | // ==================================== 13 | namespace SalarDbCodeGenerator.Schema.Database 14 | { 15 | public class DbView : DbTable 16 | { 17 | public DbView(string viewName) 18 | : base(viewName) 19 | { 20 | ReadOnly = true; 21 | TableType = TableTypeInfo.View; 22 | } 23 | public DbView(string viewName, List schemaColumns) 24 | : base(viewName, schemaColumns) 25 | { 26 | ReadOnly = true; 27 | TableType = TableTypeInfo.View; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/TableEntity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Table Entity 4 | Business model user custom methods pattern 5 | 12 | 13 | 23 | /// User custom methods for [:TableNameDb:] 24 | /// 25 | partial class [:TableName:]Entity 26 | { 27 | 28 | } 29 | } 30 | ]]> 31 | 32 | 33 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Patterns/SchemaPatternBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Xml.Serialization; 7 | 8 | namespace SalarDbCodeGenerator.Schema.Patterns 9 | { 10 | public class SchemaPatternBase where T : class 11 | { 12 | 13 | public static T ReadFromFile(string projectFilename) 14 | { 15 | T project; 16 | var loader = new XmlSerializer(typeof(T)); 17 | using (var reader = new StreamReader(projectFilename)) 18 | project = (T)loader.Deserialize(reader); 19 | return project; 20 | } 21 | 22 | public void SaveToFile(string projectFilename) 23 | { 24 | var saver = new XmlSerializer(typeof(T)); 25 | using (var writer = new StreamWriter(projectFilename)) 26 | saver.Serialize(writer, this); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/TableDAL.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User DAL 4 | Data access layer user custom methods pattern 5 | 12 | 13 | 24 | /// User custom methods for [:TableNameDb:] 25 | /// 26 | partial class [:TableName:]DAL 27 | { 28 | 29 | } 30 | } 31 | ]]> 32 | 33 | 34 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO C#/Entity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableNameDb:] 26 | /// 27 | partial class [:TableName:] 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/Entity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableNameDb:] 26 | /// 27 | partial class [:TableName:] 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate ActiveRecord WCF/Entity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableNameDb:] 26 | /// 27 | partial class [:TableName:] 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate ActiveRecord/Entity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableNameDb:] 26 | /// 27 | partial class [:TableName:] 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode Simple/Entity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 24 | /// User custom methods for [:TableNameDb:] 25 | /// 26 | partial class [:TableName:] 27 | { 28 | 29 | } 30 | } 31 | ]]> 32 | 33 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperAccess/DapperAccessUser.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity DapperAccess Object 4 | User entity DapperAccess objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableName:]Dap 26 | /// 27 | partial class [:TableName:]Dap 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperSQLinq/DapperAccessUser.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity DapperAccess Object 4 | User entity DapperAccess objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableName:]Dap 26 | /// 27 | partial class [:TableName:]Dap 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/DapperContextUser.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity DapperAccess Object 4 | User entity DapperAccess objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableName:]Dap 26 | /// 27 | partial class [:TableName:]Dap 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode MVVM/Entity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableNameDb:] 26 | /// 27 | partial class [:TableName:] 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode/Entity.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Objects 4 | User entity objects pattern 5 | 12 | 13 | 25 | /// User custom methods for [:TableNameDb:] 26 | /// 27 | partial class [:TableName:] 28 | { 29 | 30 | } 31 | } 32 | ]]> 33 | 34 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/DbConnection.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbConnection 4 | Database connection provider pattern 5 | 12 | 13 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate ActiveRecord/ActiveRecordConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ActiveRecord General config 4 | Nhibernate CastleActiveRecord configurations class 5 | 12 | 13 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/DbProject/ProjectRenaming.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SalarDbCodeGenerator.DbProject 7 | { 8 | public class ProjectRenaming 9 | { 10 | public class RenamingTaget 11 | { 12 | public bool Enabled; 13 | public bool Properties; 14 | public bool Tables; 15 | } 16 | public enum CaseChangeType 17 | { 18 | Capitalize, 19 | CamelCase, 20 | PascalCase, 21 | Lower, 22 | Upper 23 | } 24 | 25 | public ProjectRenaming() 26 | { 27 | RemoveUnderline = new RenamingTaget() { Properties = true, Tables = true, Enabled = false }; 28 | CaseChange = new RenamingTaget() {Properties = true, Tables = true, Enabled = false}; 29 | } 30 | 31 | public bool UnderlineWordDelimiter { get; set; } 32 | public RenamingTaget RemoveUnderline { get; set; } 33 | public RenamingTaget CaseChange { get; set; } 34 | public CaseChangeType CaseChangeMode { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate ActiveRecord WCF/ActiveRecordConfig.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ActiveRecord General config 4 | Nhibernate CastleActiveRecord configurations class 5 | 12 | 13 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Database/DbDatabase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SalarDbCodeGenerator.Schema.DbSchemaReaders; 6 | 7 | // ==================================== 8 | // SalarDbCodeGenerator 9 | // http://SalarDbCodeGenerator.codeplex.com 10 | // Salar Khalilzadeh 11 | // © 2012, All rights reserved 12 | // 2012/07/06 13 | // ==================================== 14 | namespace SalarDbCodeGenerator.Schema.Database 15 | { 16 | public class DbDatabase 17 | { 18 | #region properties 19 | public string DatabaseName { get; set; } 20 | public List SchemaTables { get; set; } 21 | public List SchemaViews { get; set; } 22 | 23 | public DatabaseProvider Provider { get; set; } 24 | #endregion 25 | 26 | #region public methods 27 | public DbDatabase() 28 | { 29 | SchemaTables = new List(); 30 | SchemaViews = new List(); 31 | } 32 | #endregion 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/DbConnection.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbConnection 4 | Database connection provider pattern 5 | 12 | 13 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode/DbMapper.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Mapper 4 | User objects mapper pattern 5 | 12 | 13 | 25 | /// The generator will not touch this class. 26 | /// 27 | static partial class [:DatabaseName:]Mapper 28 | { 29 | internal static void CustomMapToModel(ModelMapper mapper) 30 | { 31 | // put your custom mappings here 32 | } 33 | } 34 | } 35 | ]]> 36 | 37 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode MVVM/DbMapper.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Mapper 4 | User objects mapper pattern 5 | 12 | 13 | 25 | /// This partial class won't be toched by the generator. 26 | /// 27 | static partial class [:DatabaseName:]Mapper 28 | { 29 | internal static void CustomMapToModel(ModelMapper mapper) 30 | { 31 | // put your custom mappings here 32 | } 33 | } 34 | } 35 | ]]> 36 | 37 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode Simple/DbMapper.User.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | User Entity Mapper 4 | User objects mapper pattern 5 | 12 | 13 | 25 | /// This partial class won't be toched by the generator. 26 | /// 27 | static partial class [:DatabaseName:]Mapper 28 | { 29 | internal static void CustomMapToModel(ModelMapper mapper) 30 | { 31 | // put your custom mappings here 32 | } 33 | } 34 | } 35 | ]]> 36 | 37 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/DotNetSchemaDataInfo.cs: -------------------------------------------------------------------------------- 1 | using SalarDbCodeGenerator.Schema.Database; 2 | 3 | namespace SalarDbCodeGenerator.Schema 4 | { 5 | public class DotNetSchemaDataInfo 6 | { 7 | public const string DotNetArrayIdenticator = "[]"; 8 | 9 | public static DbColumn.ColumnCondensedType DetermineColumnCondensedType(string dotNetDataType) 10 | { 11 | switch (dotNetDataType) 12 | { 13 | case "System.String": 14 | return DbColumn.ColumnCondensedType.String; 15 | case "System.Int16": 16 | return DbColumn.ColumnCondensedType.Integer; 17 | case "System.Int32": 18 | return DbColumn.ColumnCondensedType.Integer; 19 | case "System.Int64": 20 | return DbColumn.ColumnCondensedType.Integer; 21 | case "System.Byte": 22 | return DbColumn.ColumnCondensedType.Integer; 23 | case "System.Decimal": 24 | return DbColumn.ColumnCondensedType.Decimal; 25 | case "System.Single": 26 | return DbColumn.ColumnCondensedType.Decimal; 27 | case "System.Double": 28 | return DbColumn.ColumnCondensedType.Decimal; 29 | } 30 | return DbColumn.ColumnCondensedType.None; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/DbTransaction.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbTransaction 4 | Transactions provider pattern 5 | 12 | 13 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperAccess/BaseModel.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DALBase 4 | DAL base pattern 5 | 12 | 13 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperSQLinq/BaseModel.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DALBase 4 | DAL base pattern 5 | 12 | 13 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/BaseEntity.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BaseEntity 4 | Base entity objects pattern 5 | 12 | 13 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.235 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SalarDbCodeGenerator.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/DbTransaction.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbTransaction 4 | Transactions provider pattern 5 | 12 | 13 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Database/DbConstraintKey.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | // ==================================== 7 | // SalarDbCodeGenerator 8 | // http://SalarDbCodeGenerator.codeplex.com 9 | // Salar Khalilzadeh 10 | // © 2012, All rights reserved 11 | // 2012/07/06 12 | // ==================================== 13 | namespace SalarDbCodeGenerator.Schema.Database 14 | { 15 | /// 16 | /// Constraint key details for table 17 | /// 18 | public class DbConstraintKey 19 | { 20 | #region properties 21 | /// 22 | /// Name of ForeignKey 23 | /// 24 | public string KeyName { get; set; } 25 | 26 | /// 27 | /// The column name used 28 | /// 29 | public string KeyColumnName { get; set; } 30 | 31 | /// 32 | /// The column name used 33 | /// 34 | public DbColumn KeyColumn { get; set; } 35 | 36 | /// 37 | /// Is constraint key 38 | /// 39 | public bool IsUnique { get; set; } 40 | #endregion 41 | 42 | public override string ToString() 43 | { 44 | return KeyName + ", " + KeyColumnName; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/BLLBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BLLBase 4 | BLL base pattern 5 | 12 | 13 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperSQLinq/DapperDynamicParameters.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DapperDynamicParameters 4 | 5 | 12 | 13 | Dictionary { get; private set; } 24 | 25 | public DapperDynamicParameters(IDictionary dictionary) 26 | { 27 | this.Dictionary = dictionary; 28 | } 29 | 30 | public void AddParameters(IDbCommand command, SqlMapper.Identity identity) 31 | { 32 | foreach (var pair in this.Dictionary) 33 | { 34 | IDbDataParameter parameter = command.CreateParameter(); 35 | parameter.ParameterName = pair.Key; 36 | parameter.Value = pair.Value; 37 | command.Parameters.Add(parameter); 38 | } 39 | } 40 | } 41 | } 42 | ]]> 43 | 44 | 45 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/BLLBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BLLBase 4 | BLL base pattern 5 | 12 | 13 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO C#/BaseEntity.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BaseEntity 4 | Base entity objects pattern 5 | 12 | 13 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/BaseModel.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DALBase 4 | DAL base pattern 5 | 12 | 13 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/BaseEntity.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BaseEntity 4 | Base entity objects pattern 5 | 12 | 13 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Presentation/frmBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | 10 | namespace SalarDbCodeGenerator.Presentation 11 | { 12 | public partial class frmBase : Form 13 | { 14 | public frmBase() 15 | { 16 | InitializeComponent(); 17 | } 18 | private void InitializeComponent() 19 | { 20 | this.SuspendLayout(); 21 | // 22 | // frmBase 23 | // 24 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 25 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 26 | this.ClientSize = new System.Drawing.Size(284, 262); 27 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; 28 | this.Icon = global::SalarDbCodeGenerator.Properties.Resources.AppIcon; 29 | this.MaximizeBox = false; 30 | this.MinimizeBox = false; 31 | this.Name = "frmBase"; 32 | this.ShowIcon = false; 33 | this.ShowInTaskbar = false; 34 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 35 | this.ResumeLayout(false); 36 | 37 | } 38 | protected virtual bool ValidateForm() 39 | { 40 | return this.Validate(); 41 | } 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Readme.txt: -------------------------------------------------------------------------------- 1 | Project Description 2 | This application is aimed to generate .NET class and methods for databases and model them based on customizable patterns. 3 | 4 | SalarDbCodeGenerator is a database first, code generator. It uses customizable patterns to generate different codes and models for applications. The generator engine is mostly optimized for C# but it can be used to generate any other programming language code. 5 | 6 | Supported Databases 7 | 8 | Micorsoft SQL Server (2000/2005/2008/2012) 9 | (Supports columns description) 10 | SQL Server Compact Edition 4 11 | Oracle Database (8i/9i/10g/11g) 12 | SQLite (v3 and above) 13 | 14 | Features 15 | 16 | Customizable patterns 17 | Tables foreign key relations 18 | Tables constraint keys 19 | Columns description 20 | Ignored prefixes / Ignored suffixes 21 | Prefix for tables / Suffix for tables 22 | Prefix for views / Suffix for views 23 | Renaming Options (Remove underline / Case Change / Underline is word delimiter) 24 | Default Namespace 25 | Ability to generate code for any programming language 26 | 27 | Patterns (Installed by default) 28 | * Entity Framework Code First 29 | * NHibernate Mapping By Code 30 | * NHibernate ActiveRecord 31 | * LinqToSql C# 32 | * Entity Framework 4 POCO 33 | * DapperAccess 34 | * 3Tier 35 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SalarDbCodeGenerator")] 9 | [assembly: AssemblyDescription("Database rational code generator for .NET Framework based on pattern projects.")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("SalarDbCodeGenerator")] 13 | [assembly: AssemblyCopyright("Copyright © 2009-2014 All Rights Reserved")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("c42fbf10-7fd7-4406-9e3f-48f0f0c3e68f")] 24 | 25 | [assembly: AssemblyVersion("3.0.2014.0719")] 26 | [assembly: AssemblyFileVersion("3.0.2014.0719")] -------------------------------------------------------------------------------- /SalarDbCodeGenerator/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Windows.Forms; 3 | using SalarDbCodeGenerator.DbProject; 4 | 5 | namespace SalarDbCodeGenerator 6 | { 7 | static class Program 8 | { 9 | public static string[] ProgramArgs = null; 10 | 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main(string[] args) 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | ProgramArgs = args; 20 | #if DEBUG 21 | Application.ThreadException += Application_ThreadException_Debug; 22 | #else 23 | Application.ThreadException += Application_ThreadException_Release; 24 | #endif 25 | PleaseWait.ShowPleaseWait("Initializing Systems", true, false); 26 | Application.Run(new frmCodeGen()); 27 | } 28 | 29 | static void Application_ThreadException_Debug(object sender, System.Threading.ThreadExceptionEventArgs e) 30 | { 31 | PleaseWait.Abort(); 32 | MessageBox.Show("Error, something went wrong!\n" + e.Exception.ToString(), "Unhandled error", MessageBoxButtons.OK, MessageBoxIcon.Stop); 33 | } 34 | static void Application_ThreadException_Release(object sender, System.Threading.ThreadExceptionEventArgs e) 35 | { 36 | PleaseWait.Abort(); 37 | MessageBox.Show("Error, something went wrong!\n" + Common.GetExceptionTechMessage(e.Exception), "Unhandled error", MessageBoxButtons.OK, MessageBoxIcon.Stop); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate ActiveRecord/ActiveRecord.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ActiveRecord Initializer 4 | Nhibernate CastleActiveRecord initializer 5 | 12 | 13 | 37 | 38 | 39 | [:InnerContent:] 40 | , 41 | 42 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate ActiveRecord WCF/ActiveRecord.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ActiveRecord Initializer 4 | Nhibernate CastleActiveRecord initializer 5 | 12 | 13 | 37 | 38 | 39 | [:InnerContent:] 40 | , 41 | 42 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Presentation/frmAbout.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Windows.Forms; 9 | using System.Diagnostics; 10 | 11 | namespace SalarDbCodeGenerator.Presentation 12 | { 13 | public partial class frmAbout : frmBase 14 | { 15 | public frmAbout() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void lnkEmail_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 21 | { 22 | ProcessStartInfo start = new ProcessStartInfo("mailto:" + lnkEmail.Text); 23 | try 24 | { 25 | start.UseShellExecute = true; 26 | Process.Start(start); 27 | } 28 | catch { } 29 | } 30 | 31 | private void lnkWebSite_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 32 | { 33 | ProcessStartInfo start = new ProcessStartInfo(lnkWebSite.Text); 34 | try 35 | { 36 | start.UseShellExecute = true; 37 | Process.Start(start); 38 | } 39 | catch { } 40 | } 41 | 42 | private void frmAbout_Load(object sender, EventArgs e) 43 | { 44 | lblVersion.Text = SalarDbCodeGenerator.DbProject.AppConfig.AppVersionFull; 45 | } 46 | 47 | private void lnkUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 48 | { 49 | ProcessStartInfo start = new ProcessStartInfo(lnkUpdate.Text); 50 | try 51 | { 52 | start.UseShellExecute = true; 53 | Process.Start(start); 54 | } 55 | catch { } 56 | 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/ModelBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ModelBase 4 | Model base pattern 5 | 12 | 13 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SalarDbCodeGenerator.Tests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("SalarSoft")] 12 | [assembly: AssemblyProduct("SalarDbCodeGenerator.Tests")] 13 | [assembly: AssemblyCopyright("Copyright © SalarSoft 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2429dd84-6e3f-4cc5-b450-4bc8d727ee36")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/ModelBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ModelBase 4 | Model base pattern 5 | 12 | 13 | _ 18 | Public Class ModelBase 19 | Implements IDisposable 20 | ' Fields 21 | Private _DataLoaded As Boolean = False 22 | Private _Items As Hashtable 23 | 24 | ' Methods 25 | Public Sub Dispose() Implements System.IDisposable.Dispose 26 | End Sub 27 | 28 | Public Overridable Sub ReadData(ByVal dataReader As IDataReader) 29 | End Sub 30 | 31 | Protected Sub SetDataLoaded(ByVal loaded As Boolean) 32 | Me._DataLoaded = loaded 33 | End Sub 34 | 35 | 36 | ' Properties 37 | Public ReadOnly Property DataLoaded() As Boolean 38 | Get 39 | Return Me._DataLoaded 40 | End Get 41 | End Property 42 | 43 | Default Public Property Item(ByVal name As String) As Object 44 | Get 45 | If (Me._Items Is Nothing) Then 46 | Return Nothing 47 | End If 48 | Return Me._Items.Item(name) 49 | End Get 50 | Set(ByVal value As Object) 51 | If (Me._Items Is Nothing) Then 52 | Me._Items = New Hashtable 53 | End If 54 | Me._Items.Item(name) = value 55 | End Set 56 | End Property 57 | 58 | End Class 59 | End Namespace 60 | ]]> 61 | 62 | 63 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/DapperDbConnection.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbConnectionManager 4 | Database connection manager 5 | 12 | 13 | 36 | 37 | 38 | [:InnerContent:] 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Patterns/ConditionItem.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Linq; 6 | using System.Xml.Serialization; 7 | 8 | // ==================================== 9 | // SalarDbCodeGenerator 10 | // http://SalarDbCodeGenerator.codeplex.com 11 | // Salar Khalilzadeh 12 | // © 2014, All rights reserved 13 | // ==================================== 14 | namespace SalarDbCodeGenerator.Schema.Patterns 15 | { 16 | /// 17 | /// The "Content" key with in "PatternContent" tag 18 | /// 19 | public class ConditionItem 20 | { 21 | /// 22 | /// Condition on if this item should be applied or not 23 | /// 24 | [Serializable] 25 | public enum ApplyConditionMode 26 | { 27 | NotSet, 28 | Equals, 29 | NotEquals 30 | } 31 | 32 | public ConditionItem() 33 | { 34 | Key = string.Empty; 35 | ContentText = string.Empty; 36 | } 37 | 38 | /// 39 | /// Replacement mode 40 | /// 41 | [XmlAttribute] 42 | public string Key { get; set; } 43 | 44 | /// 45 | /// Replacement Content 46 | /// 47 | [XmlText] 48 | public string ContentText { get; set; } 49 | 50 | public override string ToString() 51 | { 52 | return Key; 53 | } 54 | 55 | 56 | /// 57 | /// Condition on if this item should be applied or not 58 | /// 59 | [XmlAttribute] 60 | public ApplyConditionMode ApplyCondition { get; set; } 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/DALBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DALBase 4 | DAL base pattern 5 | 12 | 13 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/DALBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DALBase 4 | DAL base pattern 5 | 12 | 13 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/DapperConnectionContainer.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | ConnectionContainer 4 | Connection container for DAP objects 5 | 12 | 13 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/DapperModelQuery.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dapper Model Query 4 | Query pattern 5 | 12 | 13 | 22 | /// Assigns the owner property of the results 23 | /// 24 | class DapperModelQuery : IEnumerable, IEnumerator 25 | { 26 | private readonly IEnumerable _query; 27 | private readonly ConnectionContainer _dbConnection; 28 | private IEnumerator _queryEnumerator; 29 | 30 | public DapperModelQuery(IEnumerable query, ConnectionContainer dbConnection) 31 | { 32 | _query = query; 33 | _dbConnection = dbConnection; 34 | } 35 | 36 | public IEnumerator GetEnumerator() 37 | { 38 | _queryEnumerator = _query.GetEnumerator(); 39 | return this; 40 | } 41 | 42 | IEnumerator IEnumerable.GetEnumerator() 43 | { 44 | return GetEnumerator(); 45 | } 46 | 47 | public void Dispose() 48 | { 49 | if (_queryEnumerator != null) 50 | _queryEnumerator.Dispose(); 51 | } 52 | 53 | public bool MoveNext() 54 | { 55 | return _queryEnumerator.MoveNext(); 56 | } 57 | 58 | public void Reset() 59 | { 60 | _queryEnumerator.Reset(); 61 | } 62 | 63 | public T Current 64 | { 65 | get 66 | { 67 | var c = _queryEnumerator.Current; 68 | var cBase = c as BaseModel; 69 | if (cBase != null) 70 | cBase.DbConnection = _dbConnection; 71 | return c; 72 | } 73 | } 74 | 75 | object IEnumerator.Current 76 | { 77 | get { return Current; } 78 | } 79 | } 80 | } 81 | ]]> 82 | 83 | 84 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/TableBaseBLL.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | TableBaseBLL 4 | Table base pattern 5 | 12 | 13 | : BLLBase where T : class 19 | { 20 | /// 21 | /// Inserts a new record (entity) to the table 22 | /// 23 | /// Record (entity) to be inserted 24 | public virtual void Insert(T entity) 25 | { 26 | if (Transaction == null) 27 | Insert(entity, true); 28 | else 29 | Insert(entity, false); 30 | } 31 | 32 | public virtual void Insert(T entity, bool autoSave) 33 | { 34 | try 35 | { 36 | GetTable().InsertOnSubmit(entity); 37 | 38 | if (autoSave) 39 | Save(); 40 | } 41 | catch (Exception) 42 | { 43 | throw; 44 | } 45 | } 46 | 47 | /// 48 | /// Deletes a record (entity) from table 49 | /// 50 | /// Record (entity) to be deleted 51 | public void Delete(T entity) 52 | { 53 | if (Transaction == null) 54 | Delete(entity, true); 55 | else 56 | Delete(entity, false); 57 | } 58 | 59 | public void Delete(T entity, bool autoSave) 60 | { 61 | try 62 | { 63 | GetTable().DeleteOnSubmit(entity); 64 | 65 | if (autoSave) 66 | Save(); 67 | } 68 | catch (Exception) 69 | { 70 | throw; 71 | } 72 | } 73 | 74 | /// 75 | /// Saves changes to the table 76 | /// 77 | public virtual void Save() 78 | { 79 | if (DataContext == null) 80 | return; 81 | 82 | DataContext.SubmitChanges(); 83 | } 84 | } 85 | }]]> 86 | 87 | 88 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/ReleaseNotes.txt: -------------------------------------------------------------------------------- 1 | 2 | ------------------------------------ 3 | Version Next 4 | 5 | Changes: 6 | 7 | * 8 | 9 | Fixes: 10 | 11 | * Couldn't read columns description if the table has schema specified. 12 | * Bug in "CopyDataMember" of the ActiveRecord patterns is fixed. 13 | 14 | Pattern Changes: 15 | * Entity Framework pattern is updated to version 6. 16 | 17 | 18 | ------------------------------------ 19 | Version 2.1.2013.0719 2013/7/19 20 | Pattern Changes: 21 | * DapperContext pattern is added. 22 | * All patterns are updated to work with one-to-one relations. 23 | 24 | Changes: 25 | * One-to-one relation is supported. 26 | * Minor bug fixes. 27 | 28 | 29 | ------------------------------------ 30 | Version 2.0.2012.0724 2012/7/24 31 | Pattern Changes: 32 | 33 | NHibernate MappingByCode is added. 34 | NHibernate MappingByCode simple and MVVM patterns are added. 35 | DapperAccess+SQLinq pattern is added! 36 | Added connection manager for EF patterns. 37 | 38 | Changes: 39 | 40 | New database schema engine. 41 | New pattern schema engine. 42 | New generator engine. 43 | All patterns are updated. 44 | New project pattern schema. 45 | Invalid column name detection is improved. 46 | Generator overall performance improvement. 47 | Oracle columns comment supported. 48 | SQLCE columns description supported. 49 | Fixed errors reading SQLite encrypted databases. 50 | ForeignKey actions (for update and delete) are supported. 51 | 52 | Breaking changes: 53 | 54 | Version 1.0 projects are not compatible. 55 | Generated project names renamed from "[:ProjectName:]-VS2010.csproj" to "[:ProjectName:].csproj" 56 | Renamed ForeignKeys orders are changed due to new analyzer. 57 | SQLServer ForeignKeys synced by columns order. 58 | 59 | 60 | ------------------------------------ 61 | Version 1.1.2012.0518 62 | 63 | New: DapperAccess pattern is added based on Dapper mini ORM 64 | 65 | Update: EF all patterns are updated to support custom model mapping. 66 | New: One-to-One relation detection. -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO C#/EntityObjectContext.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EntityObjectContext 4 | Entity context object 5 | 12 | 13 | 53 | 54 | 55 | 56 | [:InnerContent:] 57 | 58 | _[:TableName:]; 60 | public ObjectSet<[:TableName:]> [:TableName:] 61 | { 62 | get 63 | { 64 | return _[:TableName:] ?? (_[:TableName:] = base.CreateObjectSet<[:TableName:]>()); 65 | } 66 | } 67 | ]]> 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/EntityObjectContext.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | EntityObjectContext 4 | Entity context object 5 | 12 | 13 | 53 | 54 | 55 | 56 | [:InnerContent:] 57 | 58 | [:TableName:] 60 | { 61 | get 62 | { 63 | return _[:TableName:] ?? (_[:TableName:] = base.CreateObjectSet<[:TableName:]>()); 64 | } 65 | } 66 | private ObjectSet<[:TableName:]> _[:TableName:]; 67 | ]]> 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/DbTransaction.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbTransaction 4 | Transactions provider pattern 5 | 12 | 13 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/DbProject/ProjectCodeGenSettings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Specialized; 2 | using System.IO; 3 | using System.Windows.Forms; 4 | using System; 5 | using System.Xml.Serialization; 6 | 7 | // ==================================== 8 | // SalarDbCodeGenerator 9 | // http://SalarDbCodeGenerator.codeplex.com 10 | // Salar Khalilzadeh 11 | // © 2012, All rights reserved 12 | // 2012/07/06 13 | // ==================================== 14 | namespace SalarDbCodeGenerator.DbProject 15 | { 16 | [Serializable] 17 | public class ProjectCodeGenSettings 18 | { 19 | #region properties 20 | public string DefaultNamespace { get; set; } 21 | public bool GenerateCustomizablePartial { get; set; } 22 | public string CodeGenPatternFile { get; set; } 23 | 24 | public StringCollection SelectedPatterns { get; set; } 25 | 26 | /// 27 | /// Determines if the engine should generate columns description, if is supported. 28 | /// 29 | public bool GenerateColumnsDescription { get; set; } 30 | 31 | /// 32 | /// Determines if the engine should generate tables foreign keys, if is supported. 33 | /// 34 | public bool GenerateTablesForeignKeys { get; set; } 35 | 36 | /// 37 | /// Determines if the engine should generate tables contraints keys, if supported. 38 | /// 39 | public bool GenerateConstraintKeys { get; set; } 40 | #endregion 41 | 42 | #region public methods 43 | public ProjectCodeGenSettings() 44 | { 45 | DefaultNamespace = "SalarDb.CodeGen"; 46 | GenerateColumnsDescription = true; 47 | GenerateTablesForeignKeys = true; 48 | GenerateConstraintKeys = true; 49 | CodeGenPatternFile = ""; 50 | SelectedPatterns = new StringCollection(); 51 | } 52 | public static ProjectCodeGenSettings LoadDefaultSettings() 53 | { 54 | ProjectCodeGenSettings settings = new ProjectCodeGenSettings(); 55 | 56 | settings.CodeGenPatternFile = AppConfig.AppVarApplicationPath + @"\Patterns\NHibernate MapByCode\NHibernate MapByCode.dbpat"; 57 | settings.DefaultNamespace = "SalarDb.CodeGen"; 58 | 59 | return settings; 60 | } 61 | #endregion 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /TraceAndTestImpact.testsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | These are test settings for Trace and Test Impact. 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/DbSchemaReaders/OracleQueries.txt: -------------------------------------------------------------------------------- 1 | SELECT OWNER, CONSTRAINT_NAME, TABLE_NAME, SEARCH_CONDITION, R_OWNER, R_CONSTRAINT_NAME, DELETE_RULE, STATUS, DEFERRABLE, VALIDATED, GENERATED, BAD, RELY, LAST_CHANGE, INDEX_OWNER, INDEX_NAME FROM ALL_CONSTRAINTS 2 | 3 | SELECT * FROM ALL_CONSTRAINTS 4 | 5 | SELECT * FROM ALL_CONS_COLUMNS FKCOLS 6 | SELECT * FROM FKCOLS 7 | 8 | 9 | SELECT * 10 | FROM ALL_CONSTRAINTS A INNER JOIN 11 | ALL_CONS_COLUMNS B ON (A.OWNER=B.OWNER AND B.CONSTRAINT_NAME = A.CONSTRAINT_NAME) 12 | 13 | 14 | 15 | SELECT A.OWNER, A.TABLE_NAME, Column_Name,A.CONSTRAINT_NAME,CONSTRAINT_TYPE 16 | FROM ALL_CONSTRAINTS A INNER JOIN 17 | ALL_CONS_COLUMNS B ON (A.OWNER=B.OWNER AND B.CONSTRAINT_NAME = A.CONSTRAINT_NAME) 18 | 19 | 20 | -------------------------------------------------------------------- 21 | 22 | SELECT * FROM ALL_CONS_COLUMNS FKCOLS, ALL_CONSTRAINTS FKCON where FKCOLS.OWNER = FKCON.OWNER and FKCOLS.TABLE_NAME = FKCON.TABLE_NAME and FKCOLS.CONSTRAINT_NAME = FKCON.CONSTRAINT_NAME AND FKCOLS.OWNER= FKCON.OWNER and FKCOLS.TABLE_NAME= FKCON.TABLE_NAME and FKCON.CONSTRAINT_TYPE = 'R' AND (FKCOLS.OWNER=:OWNER OR :OWNER is null) and (FKCOLS.TABLE_NAME = :TABLENAME OR :TABLENAME is null) and (FKCOLS.CONSTRAINT_NAME = :CONSTRAINTNAME OR :CONSTRAINTNAME is null) ORDER BY FKCOLS.OWNER, FKCOLS.CONSTRAINT_NAME, FKCOLS.TABLE_NAME 23 | 24 | SELECT OWNER, CONSTRAINT_NAME, TABLE_NAME, SEARCH_CONDITION, R_OWNER, R_CONSTRAINT_NAME, DELETE_RULE, STATUS, DEFERRABLE, VALIDATED, GENERATED, BAD, RELY, LAST_CHANGE, INDEX_OWNER, INDEX_NAME FROM ALL_CONSTRAINTS WHERE CONSTRAINT_TYPE = 'U' AND (OWNER = :OWNER OR :OWNER is null) AND (TABLE_NAME = :TABLENAME OR :TABLENAME is null) AND (CONSTRAINT_NAME = :CONSTRAINTNAME OR :CONSTRAINTNAME is null) 25 | 26 | 27 | SELECT INDEX_OWNER, INDEX_NAME, TABLE_OWNER, TABLE_NAME, COLUMN_NAME, COLUMN_POSITION, COLUMN_LENGTH, CHAR_LENGTH, DESCEND FROM ALL_IND_COLUMNS WHERE (INDEX_OWNER = :OWNER OR :OWNER is null) AND (INDEX_NAME = :INDEXNAME OR :INDEXNAME is null) AND (TABLE_OWNER = :TABLEOWNER OR :TABLEOWNER is null) AND (TABLE_NAME = :TABLENAME OR :TABLENAME is null) AND (COLUMN_NAME = :COLUMNNAME OR :COLUMNNAME is null) -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Patterns/PatternContent.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Linq; 6 | using System.Xml.Serialization; 7 | 8 | // ==================================== 9 | // SalarDbCodeGenerator 10 | // http://SalarDbCodeGenerator.codeplex.com 11 | // Salar Khalilzadeh 12 | // © 2012, All rights reserved 13 | // 2012/07/06 14 | // ==================================== 15 | namespace SalarDbCodeGenerator.Schema.Patterns 16 | { 17 | /// 18 | /// The pattern content in pattern file 19 | /// 20 | public class PatternContent : SchemaPatternBase 21 | { 22 | private List _conditionContents; 23 | 24 | /// 25 | /// Pattern name 26 | /// 27 | [XmlAttribute] 28 | public string Name { get; set; } 29 | 30 | /// 31 | /// Base content used for all items 32 | /// 33 | [XmlElement] 34 | public string BaseContent { get; set; } 35 | 36 | /// 37 | /// Where to apply 38 | /// 39 | [XmlAttribute] 40 | public PatternConditionKeyMode ConditionKeyMode { get; set; } 41 | 42 | /// 43 | /// The seperator between items 44 | /// 45 | [XmlElement] 46 | public string ItemsSeperator { get; set; } 47 | 48 | /// 49 | /// Pertial contents 50 | /// 51 | [XmlElement("Condition")] 52 | public List Conditions { get; set; } 53 | 54 | /// 55 | /// List if internal pattern contents 56 | /// 57 | public List ConditionContents 58 | { 59 | get 60 | { 61 | return _conditionContents ?? (_conditionContents = new List()); 62 | } 63 | } 64 | 65 | public PatternContent() 66 | { 67 | Conditions = new List(); 68 | } 69 | 70 | public ConditionItem GetReplacement(string key) 71 | { 72 | foreach (var repItem in Conditions) 73 | { 74 | if (repItem.Key == key) 75 | return repItem; 76 | } 77 | return null; 78 | } 79 | public ConditionItem GetFirst() 80 | { 81 | if (Conditions.Count > 0) 82 | return Conditions[0]; 83 | return null; 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/BLLBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BLLBase 4 | BLL base pattern 5 | 12 | 13 | : IDisposable where T : class 22 | { 23 | DataContext _dataContext = null; 24 | DbTransaction _transaction = null; 25 | 26 | public BLLBase() 27 | { 28 | } 29 | 30 | protected virtual Table GetTable() 31 | { 32 | EnsureDataContext(); 33 | if (_transaction != null) 34 | return _transaction.DataContext.GetTable(); 35 | else 36 | return _dataContext.GetTable(); 37 | } 38 | 39 | protected virtual Table GetTable() where T : class 40 | { 41 | EnsureDataContext(); 42 | if (_transaction != null) 43 | return _transaction.DataContext.GetTable(); 44 | else 45 | return _dataContext.GetTable(); 46 | } 47 | 48 | protected DataContext DataContext 49 | { 50 | get 51 | { 52 | EnsureDataContext(); 53 | if (_transaction != null) 54 | return _transaction.DataContext; 55 | else 56 | return _dataContext; 57 | } 58 | } 59 | 60 | protected virtual void EnsureDataContext() 61 | { 62 | if (_transaction == null && _dataContext == null) 63 | _dataContext = new DataContext(DbConnection.GetConnectionString()); 64 | } 65 | 66 | public DbTransaction Transaction 67 | { 68 | get { return _transaction; } 69 | set { _transaction = value; } 70 | } 71 | 72 | public virtual IQueryable GetAll() 73 | { 74 | EnsureDataContext(); 75 | try 76 | { 77 | IQueryable data; 78 | 79 | // select everything... 80 | data = from b in GetTable() select b; 81 | 82 | // return querable data... 83 | return data; 84 | } 85 | catch (Exception) 86 | { 87 | throw; 88 | } 89 | } 90 | 91 | public void Dispose() 92 | { 93 | if (_dataContext != null) 94 | _dataContext.Dispose(); 95 | } 96 | } 97 | } 98 | ]]> 99 | 100 | 101 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Database/DbForeignKey.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | // ==================================== 7 | // SalarDbCodeGenerator 8 | // http://SalarDbCodeGenerator.codeplex.com 9 | // Salar Khalilzadeh 10 | // © 2012, All rights reserved 11 | // 2012/07/06 12 | // ==================================== 13 | namespace SalarDbCodeGenerator.Schema.Database 14 | { 15 | /// 16 | /// Foreign key relation details for table 17 | /// 18 | public class DbForeignKey 19 | { 20 | public enum ForeignKeyMultiplicity { ManyToOne, OneToMany, OneToOne,/* ManyToMany*/ } 21 | #region properties 22 | /// 23 | /// Name of ForeignKey 24 | /// 25 | public string ForeignKeyName { get; set; } 26 | 27 | /// 28 | /// Represents the multiplicity information about the End of a relationship type. 29 | /// 30 | public ForeignKeyMultiplicity Multiplicity { get; set; } 31 | 32 | /// 33 | /// The column which is used as ForeignKey in current table 34 | /// 35 | public DbColumn LocalColumn { get; set; } 36 | 37 | /// 38 | /// The column which is used as ForeignKey in current table 39 | /// 40 | public string LocalColumnName { get; set; } 41 | 42 | /// 43 | /// Foreign column used for relation 44 | /// 45 | public DbColumn ForeignColumn { get; set; } 46 | 47 | /// 48 | /// Foreign column name used for relation 49 | /// 50 | public string ForeignColumnName { get; set; } 51 | 52 | /// 53 | /// Foreign table 54 | /// 55 | public DbTable ForeignTable { get; set; } 56 | 57 | private string _foreignTableName; 58 | 59 | /// 60 | /// Foreign table name 61 | /// 62 | public string ForeignTableName 63 | { 64 | get { return _foreignTableName; } 65 | set 66 | { 67 | _foreignTableName = value; 68 | ForeignTableNameInLocalTable = value; 69 | } 70 | } 71 | 72 | /// 73 | /// Foreign table name in local table 74 | /// 75 | public string ForeignTableNameInLocalTable { get; set; } 76 | 77 | 78 | public DbForeignKeyAction UpdateAction { get; set; } 79 | public DbForeignKeyAction DeleteAction { get; set; } 80 | 81 | public override string ToString() 82 | { 83 | return ForeignKeyName + " " + ForeignTableName; 84 | } 85 | #endregion 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/DbTransaction.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | DbTransaction 4 | Transactions provider pattern 5 | 12 | 13 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/ViewBLL.Principal.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Principal View BLL 4 | Busines logic layer for views pattern 5 | 12 | 13 | 25 | 26 | 27 | 28 | [:InnerContent:] 29 | 30 | 32 | /// Business logic for [:TableNameDb:] 33 | /// 34 | public partial class [:TableName:]BLL : ViewBaseBLL<[:TableName:]Entity> 35 | { 36 | [#UpdatableTable#] 37 | [#ForeignKeys#] 38 | } 39 | ]]> 40 | 41 | 42 | 43 | 44 | item.[:LocalFieldName:] == [:LocalFieldName:]).FirstOrDefault(); 48 | } 49 | 50 | public IQueryable<[:ForeignTableName:]Entity> GetForeignTableBy[:ForeignFieldNameDb:]([:ForeignFieldDotNetType:] [:ForeignFieldName:]) 51 | { 52 | return GetAll().Where(item => item.[:ForeignFieldName:] == [:ForeignFieldName:]).FirstOrDefault(); 53 | } 54 | ]]> 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | item.[:PrimaryKeyName:] == [:PrimaryKeyName:]).FirstOrDefault(); 66 | } 67 | 68 | public bool DeleteBy[:PrimaryKeyNameDb:]([:PrimaryKeyDotNetType:] [:PrimaryKeyName:]) 69 | { 70 | [:TableName:]Entity item = GetBy[:PrimaryKeyNameDb:]([:PrimaryKeyName:]); 71 | if (item == null) 72 | return false; 73 | Delete(item); 74 | return true; 75 | } 76 | ]]> 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Patterns/PatternLngSettings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Xml.Linq; 4 | using System.Xml.Serialization; 5 | 6 | // ==================================== 7 | // SalarDbCodeGenerator 8 | // http://SalarDbCodeGenerator.codeplex.com 9 | // Salar Khalilzadeh 10 | // © 2012, All rights reserved 11 | // 2012/07/06 12 | // ==================================== 13 | namespace SalarDbCodeGenerator.Schema.Patterns 14 | { 15 | [Serializable] 16 | public class PatternLngSettings : SchemaPatternBase 17 | { 18 | public string VoidDataType { get; set; } 19 | //public StringCollection NativeNullableTypes { get; set; } 20 | 21 | public string TextFieldIdenticator { get; set; } 22 | public string ArrayIdenticator { get; set; } 23 | public string DbDecimalName { get; set; } 24 | public string DbNumericName { get; set; } 25 | public string DbDecimalType { get; set; } 26 | public string DbNumericType { get; set; } 27 | public string LanguageKeywordsSuppress { get; set; } 28 | public bool KeywordsCaseSensitive { get; set; } 29 | public List LanguageKeywords { get; set; } 30 | 31 | /// 32 | /// Types that doesn't support implitic converts 33 | /// 34 | public List ExplicitCastDataTypes { get; set; } 35 | public List NullableDataTypes { get; set; } 36 | 37 | private string _languageInvalidChars; 38 | public char LanguageInvalidCharsSuppress { get; set; } 39 | public string LanguageInvalidChars 40 | { 41 | get { return _languageInvalidChars; } 42 | set 43 | { 44 | _languageInvalidChars = value; 45 | if (_languageInvalidChars != null) 46 | LanguageInvalidCharsArray = _languageInvalidChars.ToCharArray(); 47 | else 48 | LanguageInvalidCharsArray = new char[0]; 49 | } 50 | } 51 | [XmlIgnore] 52 | public char[] LanguageInvalidCharsArray { get; private set; } 53 | 54 | public PatternLngSettings() 55 | { 56 | ExplicitCastDataTypes = new List(); 57 | NullableDataTypes = new List(); 58 | LanguageKeywords = new List(); 59 | //NullableDataTypes.Add("String"); 60 | //NullableDataTypes.Add("Object"); 61 | //ExplicitCastDataTypes.Add("Object"); 62 | //ExplicitCastDataTypes.Add("Guid"); 63 | 64 | LanguageKeywordsSuppress = "{0}_{1}"; 65 | LanguageInvalidChars = ", ./<>?;'\\:\"|[]{}`-=~!@#$%^&*()+"; 66 | LanguageInvalidCharsSuppress = '_'; 67 | 68 | VoidDataType = "void"; 69 | ArrayIdenticator = "[]"; //c# 70 | TextFieldIdenticator = "text"; 71 | DbDecimalName = "decimal"; 72 | DbNumericName = "numeric"; 73 | DbDecimalType = "decimal({Precision})"; 74 | DbNumericType = "numeric({Precision},{:Scale:})"; 75 | 76 | //NativeNullableTypes = new StringCollection(); 77 | //NativeNullableTypes.Add("string"); 78 | //NativeNullableTypes.Add("object"); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/DbSchemaReaders/ExSchemaEngine.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Specialized; 3 | using SalarDbCodeGenerator.Schema.Database; 4 | 5 | // ==================================== 6 | // SalarDbCodeGenerator 7 | // http://SalarDbCodeGenerator.codeplex.com 8 | // Salar Khalilzadeh 9 | // © 2012, All rights reserved 10 | // 2012/07/06 11 | // ==================================== 12 | namespace SalarDbCodeGenerator.Schema.DbSchemaReaders 13 | { 14 | public abstract class ExSchemaEngine : IDisposable 15 | { 16 | /// 17 | /// Determines if the engine should read columns description, if supported. 18 | /// 19 | public bool ReadColumnsDescription { get; set; } 20 | 21 | /// 22 | /// Determines if the engine should read tables foreign keys, if supported. 23 | /// 24 | public bool ReadTablesForeignKeys { get; set; } 25 | 26 | /// 27 | /// Determines if the engine should generate tables constraint keys, if supported. 28 | /// 29 | public bool ReadConstraintKeys { get; set; } 30 | 31 | /// 32 | /// [Oracle only] Only get list from specific owner 33 | /// 34 | public string SpecificOwner { get; set; } 35 | 36 | /// 37 | /// Determine if the reader should only read specified selected items schema 38 | /// 39 | public bool OnlyReadSelectedItems { get; set; } 40 | 41 | /// 42 | /// Selected tables list, only their schema will be read. 43 | /// 44 | public StringCollection SelectedTables { get; set; } 45 | 46 | /// 47 | /// Selected views list, only their schema will be read. 48 | /// 49 | public StringCollection SelectedViews { get; set; } 50 | 51 | 52 | public abstract void FillSchema(DbDatabase schemaDatabase); 53 | public abstract void ReadViewsTablesList(out StringCollection tables, out StringCollection views); 54 | 55 | /// 56 | /// Gets data provider class name 57 | /// 58 | /// 59 | public abstract string GetDataProviderClassName(DataProviderClassNames providerClassName); 60 | 61 | public abstract void Dispose(); 62 | 63 | /// 64 | /// Checking to see if user has selected this table to be generated 65 | /// 66 | protected bool IsTableSelected(string tableName) 67 | { 68 | if (!OnlyReadSelectedItems) 69 | return true; 70 | if (SelectedTables == null || SelectedTables.Count==0) 71 | return false; 72 | return SelectedTables.Contains(tableName); 73 | } 74 | 75 | /// 76 | /// Checking to see if user has selected this view to be generated 77 | /// 78 | protected bool IsViewSelected(string viewName) 79 | { 80 | if (!OnlyReadSelectedItems) 81 | return true; 82 | if (SelectedViews == null || SelectedViews.Count == 0) 83 | return false; 84 | return SelectedViews.Contains(viewName); 85 | } 86 | 87 | 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Patterns/PatternProject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml.Linq; 6 | using System.Xml.Serialization; 7 | using System.IO; 8 | 9 | // ==================================== 10 | // SalarDbCodeGenerator 11 | // http://SalarDbCodeGenerator.codeplex.com 12 | // Salar Khalilzadeh 13 | // © 2012, All rights reserved 14 | // 2012/07/06 15 | // ==================================== 16 | namespace SalarDbCodeGenerator.Schema.Patterns 17 | { 18 | /// 19 | /// Patterns project 20 | /// 21 | [Serializable] 22 | public class PatternProject : SchemaPatternBase 23 | { 24 | public struct PatternFile 25 | { 26 | [XmlText] 27 | public string Path { get; set; } 28 | [XmlAttribute] 29 | public PatternsListItemAction Action { get; set; } 30 | [XmlAttribute] 31 | public string ActionCopyPath { get; set; } 32 | } 33 | 34 | /// 35 | /// Pattern name 36 | /// 37 | public string Name { get; set; } 38 | 39 | /// 40 | /// Pattern description 41 | /// 42 | public string Description { get; set; } 43 | public string Author { get; set; } 44 | public string LastUpdate { get; set; } 45 | public string Language { get; set; } 46 | public string FileExtension { get; set; } 47 | public string SupportedDatabases { get; set; } 48 | /// 49 | /// Generate referenced columns seperated 50 | /// 51 | public bool SeperateReferenceColumns { get; set; } 52 | public PatternLngSettings LanguageSettings { get; set; } 53 | 54 | [XmlElement("PatternFile")] 55 | public List PatternFiles { get; set; } 56 | 57 | /// 58 | /// Pattern project file name 59 | /// 60 | [NonSerialized] 61 | public string PatternFileName; 62 | 63 | public PatternProject() 64 | { 65 | PatternFiles = new List(); 66 | LanguageSettings = new PatternLngSettings(); 67 | } 68 | 69 | public bool Equals(PatternProject patProject) 70 | { 71 | return patProject.Name == Name && 72 | patProject.Description == Description && 73 | patProject.Author == Author && 74 | patProject.Language == Language && 75 | patProject.LastUpdate == LastUpdate && 76 | patProject.FileExtension == FileExtension; 77 | } 78 | 79 | public static new PatternProject ReadFromFile(string projectFilename) 80 | { 81 | PatternProject project; 82 | var loader = new XmlSerializer(typeof(PatternProject)); 83 | using (var reader = new StreamReader(projectFilename)) 84 | project = (PatternProject)loader.Deserialize(reader); 85 | 86 | project.PatternFileName = projectFilename; 87 | return project; 88 | } 89 | 90 | } 91 | 92 | 93 | public enum PatternsListItemAction 94 | { 95 | Generate, 96 | Copy 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode MVVM/Entity.DataAnnotations.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Data Annotations Entity Objects 4 | Data annotations entity objects pattern 5 | 12 | 13 | 25 | /// Data annotations attributes for [:TableNameDb:]. 26 | /// This class won't update by generator. Delete this file to get updated fields. 27 | /// 28 | public class [:TableName:]Meta 29 | { 30 | [#FieldsProperties#] 31 | } 32 | } 33 | ]]> 34 | 35 | 36 | 37 | 38 | 42 | 43 | 44 | 48 | 49 | 50 | 54 | 55 | 56 | 60 | 61 | 62 | 66 | 67 | 68 | 72 | 73 | 74 | 78 | 79 | 80 | 84 | 85 | 86 | 90 | 91 | 92 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/BLLBase.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | BLLBase 4 | BLL base pattern 5 | 12 | 13 | 33 | /// Determines to auto save the actions or not. Autosave doesn't apply when transaction is set. 34 | /// 35 | public [:DatabaseName:]BLLBase(bool autoSave) 36 | { 37 | _autoSave = autoSave; 38 | } 39 | 40 | public [:DatabaseName:]Entities ObjectContext 41 | { 42 | get 43 | { 44 | EnsureObjectContext(); 45 | return _objectContext; 46 | } 47 | } 48 | 49 | /// 50 | /// Determines to auto-save the actions immediately or not. Autosave won't apply if the Transaction is set. 51 | /// 52 | public bool AutoSaveChanges 53 | { 54 | get { return _autoSave; } 55 | } 56 | 57 | /// 58 | /// The transaction used to delay save changes between BLLs. 59 | /// 60 | public [:DatabaseName:]Transaction Transaction 61 | { 62 | get { return _transaction; } 63 | set 64 | { 65 | _transaction = value; 66 | _objectContext = _transaction.ObjectContext; 67 | } 68 | } 69 | 70 | /// 71 | /// Saves any changes and ignores the transaction. 72 | /// 73 | public void SaveChanges(bool force) 74 | { 75 | if (!force && _transaction != null) 76 | { 77 | return; 78 | } 79 | ObjectContext.SaveChanges(); 80 | } 81 | 82 | /// 83 | /// Saves any changes and ignores the transaction. 84 | /// 85 | public void SaveChanges() 86 | { 87 | SaveChanges(false); 88 | } 89 | 90 | /// 91 | /// Save changes if auto save is enabled 92 | /// 93 | protected void AutoSave() 94 | { 95 | if (_autoSave) 96 | { 97 | SaveChanges(); 98 | } 99 | } 100 | 101 | private void CreateObjectContext() 102 | { 103 | _objectContext = new [:DatabaseName:]Entities([:DatabaseName:]Connection.GetConnectionString()); 104 | } 105 | 106 | private void EnsureObjectContext() 107 | { 108 | if (_objectContext == null) 109 | { 110 | CreateObjectContext(); 111 | } 112 | } 113 | 114 | public void Dispose() 115 | { 116 | if (_objectContext!=null) 117 | { 118 | _objectContext.Dispose(); 119 | } 120 | _objectContext = null; 121 | } 122 | } 123 | }]]> 124 | 125 | 126 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/NHibernate MapByCode/Entity.DataAnnotations.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Data Annotations Entity Objects 4 | Data annotations entity objects pattern 5 | 12 | 13 | 25 | /// Data annotations attributes for [:TableNameDb:]. 26 | /// This class won't update by generator. Delete this file to get updated fields. 27 | /// 28 | public class [:TableName:]Meta 29 | { 30 | [#FieldsProperties#] 31 | } 32 | } 33 | ]]> 34 | 35 | 36 | 37 | 38 | 42 | 43 | 44 | 48 | 49 | 50 | 54 | 55 | 56 | 60 | 61 | 62 | 66 | 67 | 68 | 72 | 73 | 74 | 78 | 79 | 80 | 84 | 85 | 86 | 90 | 91 | 92 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/DapperContext.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Dapper Context 4 | Dapper context for entities 5 | 12 | 13 | 71 | 72 | 73 | 74 | [:InnerContent:] 75 | 76 | 90 | 91 | 92 | 93 | [:InnerContent:] 94 | 95 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {EB2AA099-A9B3-458A-BF18-02BE8E7C6262} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v2.0 26 | 512 27 | 28 | 29 | true 30 | full 31 | false 32 | bin\Debug\ 33 | DEBUG;TRACE 34 | prompt 35 | 4 36 | 37 | 38 | pdbonly 39 | true 40 | bin\Release\ 41 | TRACE 42 | prompt 43 | 4 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | [#ProjectItems#] 54 | 55 | 56 | [#ProjectAppConfig#] 57 | 58 | 59 | 66 | 67 | ]]> 68 | 69 | 70 | 71 | 72 | ]]> 74 | 75 | 76 | 77 | 78 | 79 | ]]> 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier C#/VS2008ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2008 ClassProject 4 | Visual Studio 2008 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {EB2AA099-A9B3-458A-BF18-02BE8E7C6262} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v2.0 26 | 512 27 | 28 | 29 | true 30 | full 31 | false 32 | bin\Debug\ 33 | DEBUG;TRACE 34 | prompt 35 | 4 36 | 37 | 38 | pdbonly 39 | true 40 | bin\Release\ 41 | TRACE 42 | prompt 43 | 4 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | [#ProjectItems#] 54 | 55 | 56 | [#ProjectAppConfig#] 57 | 58 | 59 | 66 | 67 | ]]> 68 | 69 | 70 | 71 | 72 | ]]> 74 | 75 | 76 | 77 | 78 | 79 | ]]> 80 | 81 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {EB2AA099-A9B3-458A-BF18-02BE8E7C6262} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v3.5 26 | 512 27 | 28 | 29 | true 30 | full 31 | false 32 | bin\Debug\ 33 | DEBUG;TRACE 34 | prompt 35 | 4 36 | 37 | 38 | pdbonly 39 | true 40 | bin\Release\ 41 | TRACE 42 | prompt 43 | 4 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | [#ProjectItems#] 56 | 57 | 58 | [#ProjectAppConfig#] 59 | 60 | 61 | 68 | 69 | ]]> 70 | 71 | 72 | 73 | 74 | ]]> 76 | 77 | 78 | 79 | 80 | 81 | ]]> 82 | 83 | 84 | 85 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/VS2008ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2008 ClassProject 4 | Visual Studio 2008 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {EB2AA099-A9B3-458A-BF18-02BE8E7C6262} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v3.5 26 | 512 27 | 28 | 29 | true 30 | full 31 | false 32 | bin\Debug\ 33 | DEBUG;TRACE 34 | prompt 35 | 4 36 | 37 | 38 | pdbonly 39 | true 40 | bin\Release\ 41 | TRACE 42 | prompt 43 | 4 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | [#ProjectItems#] 56 | 57 | 58 | [#ProjectAppConfig#] 59 | 60 | 61 | 68 | 69 | ]]> 70 | 71 | 72 | 73 | 74 | ]]> 76 | 77 | 78 | 79 | 80 | 81 | ]]> 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperAccess/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {EB2AA099-A9B3-458A-BF18-02BE8E7C6262} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v4.0 26 | Client 27 | 512 28 | 29 | 30 | true 31 | full 32 | false 33 | bin\Debug\ 34 | DEBUG;TRACE 35 | prompt 36 | 4 37 | 38 | 39 | pdbonly 40 | true 41 | bin\Release\ 42 | TRACE 43 | prompt 44 | 4 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | [#ProjectItems#] 59 | 60 | 61 | [#ProjectAppConfig#] 62 | 63 | 64 | 71 | 72 | ]]> 73 | 74 | 75 | 76 | 77 | ]]> 79 | 80 | 81 | 82 | 83 | 84 | ]]> 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperContext/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {EB2AA099-A9B3-458A-BF18-02BE8E7C6262} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v4.0 26 | Client 27 | 512 28 | 29 | 30 | true 31 | full 32 | false 33 | bin\Debug\ 34 | DEBUG;TRACE 35 | prompt 36 | 4 37 | 38 | 39 | pdbonly 40 | true 41 | bin\Release\ 42 | TRACE 43 | prompt 44 | 4 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | [#ProjectItems#] 59 | 60 | 61 | [#ProjectAppConfig#] 62 | 63 | 64 | 71 | 72 | ]]> 73 | 74 | 75 | 76 | 77 | ]]> 79 | 80 | 81 | 82 | 83 | 84 | ]]> 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator.Tests/GenerationTestBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Text; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | using SalarDbCodeGenerator.DbProject; 8 | using SalarDbCodeGenerator.Schema.Database; 9 | using SalarDbCodeGenerator.Schema.DbSchemaReaders; 10 | using SalarDbCodeGenerator.Schema.Patterns; 11 | 12 | namespace SalarDbCodeGenerator.Tests 13 | { 14 | [TestClass] 15 | public class GenerationTestBase 16 | { 17 | public ProjectDefinaton Project { get; set; } 18 | public PatternProject Pattern { get; set; } 19 | public DbDatabase Database { get; set; } 20 | 21 | [TestInitialize] 22 | public void InitializeSchemaProject() 23 | { 24 | Project = new ProjectDefinaton(); 25 | Pattern = new PatternProject(); 26 | Database = new DbDatabase(); 27 | 28 | Project.GenerationPath = Path.Combine(Path.GetTempPath(), @"SalarDbCodeGenerator.Tests\" + DateTime.Now.Ticks); 29 | Project.ProjectName = "SalarDbCodeGenerator.Tests"; 30 | 31 | Pattern.LanguageSettings.KeywordsCaseSensitive = true; 32 | Pattern.LanguageSettings.LanguageInvalidChars = ", ./<>?;'\\:\"|[]{}`-=~!@#$%^&*()+"; 33 | Pattern.LanguageSettings.LanguageInvalidCharsSuppress = '_'; 34 | Pattern.LanguageSettings.LanguageKeywords.AddRange(new string[] 35 | { 36 | "readonly", "base", "break", "byte", "case", "catch", "checked", 37 | "class", "const", "continue", "default", "delegate", "do", 38 | "value", "else", "enum", "event", "explicit", "extern", "false", 39 | "finally", "fixed", "for", "foreach", "goto", "if", "implicit", 40 | "in", "interface", "internal", "is", "namespace", "new", "null", 41 | "object", "operator", "out", "override", "private", "protected", 42 | "public", "readonly", "ref", "return", "sealed", "sizeof", 43 | "static", "struct", "switch", "this", "throw", "true", "try", 44 | "typeof", "typeof", "unchecked", "unsafe", "using", "virtual", 45 | "while" 46 | }); 47 | Pattern.LanguageSettings.NullableDataTypes.AddRange(new[] { "String", "Object" }); 48 | Pattern.LanguageSettings.ExplicitCastDataTypes.AddRange(new[] { "Object", "Guid", "DateTimeOffset", "TimeSpan" }); 49 | Pattern.LanguageSettings.VoidDataType = "void"; 50 | Pattern.LanguageSettings.TextFieldIdenticator = "text"; 51 | Pattern.LanguageSettings.ArrayIdenticator = "[]"; 52 | Pattern.LanguageSettings.DbDecimalName = "decimal"; 53 | Pattern.LanguageSettings.DbNumericName = "numeric"; 54 | Pattern.LanguageSettings.DbDecimalType = "decimal([:Precision:],[:Scale:])"; 55 | Pattern.LanguageSettings.DbNumericType = "numeric([:Precision:],[:Scale:])"; 56 | Pattern.LanguageSettings.LanguageKeywordsSuppress = "{0}_{1}"; 57 | 58 | 59 | Database.DatabaseName = "SalarDbCodeGeneratorTests"; 60 | Database.Provider = DatabaseProvider.SQLServer; 61 | } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Schema/Database/DbColumn.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | // ==================================== 7 | // SalarDbCodeGenerator 8 | // http://SalarDbCodeGenerator.codeplex.com 9 | // Salar Khalilzadeh 10 | // © 2012, All rights reserved 11 | // 2012/07/07 12 | // ==================================== 13 | namespace SalarDbCodeGenerator.Schema.Database 14 | { 15 | public class DbColumn 16 | { 17 | public enum ColumnCondensedType 18 | { 19 | None, 20 | String, 21 | Decimal, 22 | Integer 23 | } 24 | 25 | #region properties 26 | public bool AutoIncrement { get; set; } 27 | public string DataTypeDb { get; set; } 28 | public string DataTypeDotNet { get; set; } 29 | 30 | /// 31 | /// Determined special type of column 32 | /// 33 | public ColumnCondensedType DataCondensedType { get; set; } 34 | public int Length { get; set; } 35 | public bool PrimaryKey { get; set; } 36 | private bool _allowNull; 37 | public bool AllowNull 38 | { 39 | get { return _allowNull; } 40 | set 41 | { 42 | _allowNull = value; 43 | DataTypeNullable = value; 44 | } 45 | } 46 | public bool DataTypeNullable { get; set; } 47 | 48 | /// 49 | /// Datatype can not be converted by simple implitic converts 50 | /// 51 | public bool ExplicitCastDataType { get; set; } 52 | 53 | private string _fieldNameDb; 54 | 55 | /// 56 | /// Exact field name in database 57 | /// 58 | public string FieldNameDb 59 | { 60 | get { return _fieldNameDb; } 61 | set 62 | { 63 | _fieldNameDb = value; 64 | FieldNameSchema = _fieldNameDb; 65 | } 66 | } 67 | 68 | /// 69 | /// Field name in the schema, after duplicate checks. Renamed name. 70 | /// 71 | public string FieldNameSchema { get; set; } 72 | 73 | /// 74 | /// CHARACTER_MAXIMUM_LENGTH is actual len of the column, how many bytes it can save 75 | /// 76 | public int DataTypeMaxLength { get; set; } 77 | 78 | /// 79 | /// Len is maximum possible!? 80 | /// 81 | //public bool LengthIsMax { get; set; } 82 | 83 | /// 84 | /// Is referenced to other tables 85 | /// 86 | public bool IsReferenceKey { get; set; } 87 | 88 | /// 89 | /// Referenced to other tables 90 | /// 91 | public DbTable IsReferenceKeyTable { get; set; } 92 | 93 | public string Owner { get; set; } 94 | 95 | public int ColumnOrdinal { get; set; } 96 | public int NumericScale { get; set; } 97 | public int NumericPrecision { get; set; } 98 | 99 | /// 100 | /// Description which is applied in tables 101 | /// 102 | public string UserDescription { get; set; } 103 | 104 | //public string DataTypeDotNetClean { get; set; } 105 | 106 | public string SequenceName { get; set; } 107 | #endregion 108 | 109 | #region public methods 110 | public DbColumn(string fieldName) 111 | { 112 | FieldNameDb = fieldName; 113 | } 114 | public bool IsArray(string arrayIndicator) 115 | { 116 | return this.DataTypeDotNet.Contains(arrayIndicator); 117 | } 118 | #endregion 119 | 120 | #region protected methods 121 | public override string ToString() 122 | { 123 | return FieldNameDb + ", " + DataTypeDotNet; 124 | } 125 | #endregion 126 | 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/DapperSQLinq/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {EB2AA099-A9B3-458A-BF18-02BE8E7C6262} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v4.0 26 | Client 27 | 512 28 | 29 | 30 | true 31 | full 32 | false 33 | bin\Debug\ 34 | DEBUG;TRACE 35 | prompt 36 | 4 37 | 38 | 39 | pdbonly 40 | true 41 | bin\Release\ 42 | TRACE 43 | prompt 44 | 4 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | References\SQLinq.dll 58 | 59 | 60 | 61 | [#ProjectItems#] 62 | 63 | 64 | [#ProjectAppConfig#] 65 | 66 | 67 | 74 | 75 | ]]> 76 | 77 | 78 | 79 | 80 | ]]> 82 | 83 | 84 | 85 | 86 | 87 | ]]> 88 | 89 | 90 | 91 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/DbProject/ProjectDefinaton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Windows.Forms; 4 | using System.Xml.Serialization; 5 | 6 | // ==================================== 7 | // SalarDbCodeGenerator 8 | // http://SalarDbCodeGenerator.codeplex.com 9 | // Salar Khalilzadeh 10 | // © 2012, All rights reserved 11 | // 2012/07/06 12 | // ==================================== 13 | namespace SalarDbCodeGenerator.DbProject 14 | { 15 | [Serializable] 16 | public class ProjectDefinaton : ICloneable 17 | { 18 | #region local variables 19 | #endregion 20 | 21 | #region field variables 22 | #endregion 23 | 24 | #region properties 25 | 26 | private float _generatorVersion; 27 | public float GeneratorVersion 28 | { 29 | get { return _generatorVersion; } 30 | set { /* nope! this doesn't change!*/ } 31 | } 32 | 33 | public string ProjectName { get; set; } 34 | public DateTime LastGeneration { get; set; } 35 | public string GenerationPath { get; set; } 36 | public ProjectCodeGenSettings CodeGenSettings { get; set; } 37 | public ProjectDbSettions DbSettions { get; set; } 38 | public ProjectRenaming RenamingOptions { get; set; } 39 | 40 | [NonSerialized] 41 | public string ProjectFileName; 42 | #endregion 43 | 44 | #region public methods 45 | public ProjectDefinaton() 46 | { 47 | ProjectName = "Project1"; 48 | LastGeneration = DateTime.MinValue; 49 | GenerationPath = ""; 50 | DbSettions = new ProjectDbSettions(); 51 | CodeGenSettings = new ProjectCodeGenSettings(); 52 | RenamingOptions = new ProjectRenaming(); 53 | _generatorVersion = 2.1f; 54 | } 55 | 56 | public object Clone() 57 | { 58 | return this.MemberwiseClone(); 59 | } 60 | 61 | public static void SaveToFile(ProjectDefinaton definaton, string fileName) 62 | { 63 | var genPath = definaton.GenerationPath; 64 | var patPath = definaton.CodeGenSettings.CodeGenPatternFile; 65 | try 66 | { 67 | // make relative 68 | definaton.CodeGenSettings.CodeGenPatternFile = 69 | Common.AppVarPathMakeRelative(definaton.CodeGenSettings.CodeGenPatternFile); 70 | definaton.GenerationPath = Common.ProjectPathMakeRelative(definaton.GenerationPath, fileName); 71 | 72 | // save 73 | XmlSerializer saver = new XmlSerializer(typeof(ProjectDefinaton)); 74 | using (StreamWriter writer = new StreamWriter(fileName)) 75 | saver.Serialize(writer, definaton); 76 | 77 | } 78 | finally 79 | { 80 | // restore 81 | definaton.CodeGenSettings.CodeGenPatternFile = patPath; 82 | definaton.GenerationPath = genPath; 83 | } 84 | } 85 | public static ProjectDefinaton LoadFromFile(string fileName) 86 | { 87 | ProjectDefinaton definaton; 88 | XmlSerializer loader = new XmlSerializer(typeof(ProjectDefinaton)); 89 | using (StreamReader reader = new StreamReader(fileName)) 90 | definaton = (ProjectDefinaton)loader.Deserialize(reader); 91 | 92 | definaton.ProjectFileName = fileName; 93 | return definaton; 94 | } 95 | public static ProjectDefinaton LoadDefaultProject() 96 | { 97 | ProjectDefinaton result = new ProjectDefinaton(); 98 | 99 | result.ProjectName = "Project1"; 100 | result.LastGeneration = DateTime.MinValue; 101 | result.GenerationPath = AppConfig.DefaultOutputPath; 102 | result.ProjectFileName = ""; 103 | 104 | result.DbSettions = ProjectDbSettions.LoadDefaultSettings(); 105 | result.CodeGenSettings = ProjectCodeGenSettings.LoadDefaultSettings(); 106 | result.CodeGenSettings.CodeGenPatternFile = AppConfig.DefaultPatternFileName; 107 | 108 | return result; 109 | } 110 | 111 | #endregion 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO C#/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {0733794C-CD3B-48E6-99B2-32933E794609} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v4.0 26 | Client 27 | 512 28 | 29 | 30 | true 31 | full 32 | false 33 | bin\Debug\ 34 | DEBUG;TRACE 35 | prompt 36 | 4 37 | 38 | 39 | pdbonly 40 | true 41 | bin\Release\ 42 | TRACE 43 | prompt 44 | 4 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | [#ProjectItems#] 65 | 66 | 67 | [#ProjectAppConfig#] 68 | 69 | 70 | 77 | 78 | ]]> 79 | 80 | 81 | 82 | 83 | ]]> 85 | 86 | 87 | 88 | 89 | 90 | ]]> 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/EF4 POCO LINQ C#/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {0733794C-CD3B-48E6-99B2-32933E794609} 21 | Library 22 | Properties 23 | [:Namespace:] 24 | [:ProjectName:] 25 | v4.0 26 | Client 27 | 512 28 | 29 | 30 | true 31 | full 32 | false 33 | bin\Debug\ 34 | DEBUG;TRACE 35 | prompt 36 | 4 37 | 38 | 39 | pdbonly 40 | true 41 | bin\Release\ 42 | TRACE 43 | prompt 44 | 4 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | [#ProjectItems#] 65 | 66 | 67 | [#ProjectAppConfig#] 68 | 69 | 70 | 77 | 78 | ]]> 79 | 80 | 81 | 82 | 83 | ]]> 85 | 86 | 87 | 88 | 89 | 90 | ]]> 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/LinqToSql C#/TableBLL.Principal.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Principal BLL 4 | Busines logic layer for tables pattern 5 | 12 | 13 | 25 | 26 | 27 | 28 | [:InnerContent:] 29 | 30 | 32 | /// Business logic for [:TableNameDb:] 33 | /// 34 | public partial class [:TableName:]BLL : TableBaseBLL<[:TableName:]Entity> 35 | { 36 | [#UpdatableTable#] 37 | [#ForeignKeys#] 38 | [#IndexConstraintKeys#] 39 | [#UniqueConstraintKeys#] 40 | } 41 | ]]> 42 | 43 | 44 | 45 | 46 | 47 | 48 | GetBy[:LocalFieldName:]([:LocalFieldDotNetType:] [:LocalFieldName:]) 50 | { 51 | return GetAll().Where(item => item.[:LocalFieldName:] == [:LocalFieldName:]); 52 | }]]> 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | GetBy[:IndexKeyName:]([:IndexKeyDotNetType:] [:IndexKeyName:]) 62 | { 63 | return GetAll().Where(item => item.[:IndexKeyName:] == [:IndexKeyName:]); 64 | }]]> 65 | 66 | 67 | 68 | 69 | 70 | item.[:IndexKeyName:] == [:IndexKeyName:]).FirstOrDefault(); 74 | } 75 | 76 | public bool DeleteBy[:IndexKeyName:]([:IndexKeyDotNetType:] [:IndexKeyName:]) 77 | { 78 | [:TableName:]Entity item = GetBy[:IndexKeyName:]([:IndexKeyName:]); 79 | if (item == null) 80 | return false; 81 | Delete(item); 82 | return true; 83 | }]]> 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | item.[:PrimaryKeyName:] == [:PrimaryKeyName:]).FirstOrDefault(); 95 | } 96 | 97 | public bool DeleteBy[:PrimaryKeyName:]([:PrimaryKeyDotNetType:] [:PrimaryKeyName:]) 98 | { 99 | [:TableName:]Entity item = GetBy[:PrimaryKeyName:]([:PrimaryKeyName:]); 100 | if (item == null) 101 | return false; 102 | Delete(item); 103 | return true; 104 | }]]> 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/VS2010ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2010 ClassProject 4 | Visual Studio 2010 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {ECFD326B-DBCF-4184-B776-31CAD6D0BFE3} 21 | Library 22 | [:Namespace:] 23 | [:ProjectName:] 24 | 512 25 | Windows 26 | v2.0 27 | On 28 | Binary 29 | Off 30 | On 31 | 32 | 33 | true 34 | full 35 | true 36 | true 37 | bin\Debug\ 38 | ClassLibrary2.xml 39 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 40 | 41 | 42 | pdbonly 43 | false 44 | true 45 | true 46 | bin\Release\ 47 | ClassLibrary2.xml 48 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | [#ProjectItems#] 67 | 68 | 69 | [#ProjectAppConfig#] 70 | 71 | 72 | 79 | 80 | ]]> 81 | 82 | 83 | 84 | ]]> 86 | 87 | 88 | 89 | 90 | 91 | ]]> 92 | 93 | 94 | 95 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/VS2008ClassProject.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | VS2008 ClassProject 4 | Visual Studio 2008 Class Project 5 | 12 | 13 | 14 | 15 | 16 | Debug 17 | AnyCPU 18 | 9.0.30729 19 | 2.0 20 | {ECFD326B-DBCF-4184-B776-31CAD6D0BFE3} 21 | Library 22 | [:Namespace:] 23 | [:ProjectName:] 24 | 512 25 | Windows 26 | v2.0 27 | On 28 | Binary 29 | Off 30 | On 31 | 32 | 33 | true 34 | full 35 | true 36 | true 37 | bin\Debug\ 38 | ClassLibrary2.xml 39 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 40 | 41 | 42 | pdbonly 43 | false 44 | true 45 | true 46 | bin\Release\ 47 | ClassLibrary2.xml 48 | 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | [#ProjectItems#] 67 | 68 | 69 | [#ProjectAppConfig#] 70 | 71 | 72 | 79 | 80 | ]]> 81 | 82 | 83 | 84 | ]]> 86 | 87 | 88 | 89 | 90 | 91 | ]]> 92 | 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SalarDbCodeGenerator", "SalarDbCodeGenerator\SalarDbCodeGenerator.csproj", "{5E8980A3-BB52-4D49-929F-24C67DCC046F}" 5 | EndProject 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SalarDbCodeGenerator.Tests", "SalarDbCodeGenerator.Tests\SalarDbCodeGenerator.Tests.csproj", "{021D6481-98E5-4EAD-8E5F-CA5596C368B7}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{497869E3-B661-4888-BB04-E9987752857B}" 9 | ProjectSection(SolutionItems) = preProject 10 | Local.testsettings = Local.testsettings 11 | SalarDbCodeGenerator.vsmdi = SalarDbCodeGenerator.vsmdi 12 | TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings 13 | EndProjectSection 14 | EndProject 15 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D826DFFA-8658-4C2A-B675-1D9382ADC53A}" 16 | ProjectSection(SolutionItems) = preProject 17 | .nuget\NuGet.Config = .nuget\NuGet.Config 18 | .nuget\NuGet.exe = .nuget\NuGet.exe 19 | .nuget\NuGet.targets = .nuget\NuGet.targets 20 | EndProjectSection 21 | EndProject 22 | Global 23 | GlobalSection(TestCaseManagementSettings) = postSolution 24 | CategoryFile = SalarDbCodeGenerator.vsmdi 25 | EndGlobalSection 26 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 27 | Debug|Any CPU = Debug|Any CPU 28 | Debug|Mixed Platforms = Debug|Mixed Platforms 29 | Debug|x86 = Debug|x86 30 | Release|Any CPU = Release|Any CPU 31 | Release|Mixed Platforms = Release|Mixed Platforms 32 | Release|x86 = Release|x86 33 | EndGlobalSection 34 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 35 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 36 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Debug|Any CPU.Build.0 = Debug|Any CPU 37 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 38 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Debug|Mixed Platforms.Build.0 = Debug|x86 39 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Debug|x86.ActiveCfg = Debug|x86 40 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Debug|x86.Build.0 = Debug|x86 41 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Release|Any CPU.ActiveCfg = Release|Any CPU 42 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Release|Any CPU.Build.0 = Release|Any CPU 43 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Release|Mixed Platforms.ActiveCfg = Release|x86 44 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Release|Mixed Platforms.Build.0 = Release|x86 45 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Release|x86.ActiveCfg = Release|x86 46 | {5E8980A3-BB52-4D49-929F-24C67DCC046F}.Release|x86.Build.0 = Release|x86 47 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 48 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Debug|Any CPU.Build.0 = Debug|Any CPU 49 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 50 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Debug|Mixed Platforms.Build.0 = Debug|x86 51 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Debug|x86.ActiveCfg = Debug|x86 52 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Debug|x86.Build.0 = Debug|x86 53 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Release|Any CPU.ActiveCfg = Release|Any CPU 54 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Release|Mixed Platforms.ActiveCfg = Release|x86 55 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Release|Mixed Platforms.Build.0 = Release|x86 56 | {021D6481-98E5-4EAD-8E5F-CA5596C368B7}.Release|x86.ActiveCfg = Release|x86 57 | EndGlobalSection 58 | GlobalSection(SolutionProperties) = preSolution 59 | HideSolutionNode = FALSE 60 | EndGlobalSection 61 | GlobalSection(ExtensibilityGlobals) = postSolution 62 | VisualSVNWorkingCopyRoot = . 63 | EndGlobalSection 64 | EndGlobal 65 | -------------------------------------------------------------------------------- /SalarDbCodeGenerator/Patterns/3Tier VB.NET/TableBLL.Principal.patml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Database BLL 4 | Business logic layer pattern 5 | 12 | 13 | 22 | 23 | 24 | 25 | [:InnerContent:] 26 | 27 | 29 | ''' Business logic for [:TableNameDb:] 30 | ''' 31 | Partial Public Class [:TableName:]BLL 32 | Inherits BLLBase 33 | 34 | Public Function GetAll() As List(Of [:TableName:]Model) 35 | Using dal As [:TableName:]DAL = New [:TableName:]DAL(MyBase.Transaction, MyBase.Connection) 36 | Return dal.GetAll 37 | End Using 38 | End Function 39 | 40 | [#UpdatableTable#] 41 | End Class 42 | ]]> 43 | 44 | 45 | 46 | 47 | 48 | 51 | 52 | 53 | 74 | 75 | 76 | 77 | 78 | 85 | 86 | 87 | 94 | 95 | 96 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | --------------------------------------------------------------------------------