├── Demo.png
├── POCOGenerator
├── Resources
│ └── code.ico
├── app.config
├── Extenders
│ ├── ObjectExtender.cs
│ ├── StringExtender.cs
│ └── AssemblyExtender.cs
├── Program.cs
├── Entities
│ ├── ResultItem.cs
│ ├── ConnectionItem.cs
│ ├── Settings.cs
│ └── SqlColumn.cs
├── POCOGenerator.csproj.DotSettings
├── Properties
│ ├── DataSources
│ │ ├── POCOGenerator.Entities.SqlColumn.datasource
│ │ ├── POCOGenerator.Entities.ResultItem.datasource
│ │ └── POCOGenerator.Entities.ConnectionItem.datasource
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── DomainServices
│ ├── SettingsHandler.cs
│ └── SqlParser.cs
├── Controls
│ ├── ResultContent.cs
│ ├── ResultContent.resx
│ └── ResultContent.Designer.cs
├── POCOGenerator.sln
├── Connection.cs
├── POCOGenerator.csproj
├── Connection.Designer.cs
├── Connection.resx
├── Main.cs
└── Main.Designer.cs
├── README.md
└── .gitignore
/Demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaklithn/POCOGenerator/HEAD/Demo.png
--------------------------------------------------------------------------------
/POCOGenerator/Resources/code.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jaklithn/POCOGenerator/HEAD/POCOGenerator/Resources/code.ico
--------------------------------------------------------------------------------
/POCOGenerator/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/POCOGenerator/Extenders/ObjectExtender.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 |
4 | namespace POCOGenerator.Extenders
5 | {
6 | public static class ObjectExtender
7 | {
8 | public static object GetPropertyValue(this object obj, string propertyName)
9 | {
10 | return obj.GetType().GetProperties().Single(pi => pi.Name == propertyName).GetValue(obj, null);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/POCOGenerator/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Forms;
3 |
4 |
5 | namespace POCOGenerator
6 | {
7 | internal static class Program
8 | {
9 | [STAThread]
10 | private static void Main()
11 | {
12 | Application.EnableVisualStyles();
13 | Application.SetCompatibleTextRenderingDefault(false);
14 | Application.Run(new Main());
15 | }
16 | }
17 | }
--------------------------------------------------------------------------------
/POCOGenerator/Entities/ResultItem.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Data;
3 |
4 |
5 | namespace POCOGenerator.Entities
6 | {
7 | public class ResultItem
8 | {
9 | public string EntityName { get; set; }
10 | public DataTable SchemaTable { get; set; }
11 | public DataTable DataTable { get; set; }
12 | public List SqlColumns { get; set; }
13 | public string Code { get; set; }
14 | }
15 | }
--------------------------------------------------------------------------------
/POCOGenerator/POCOGenerator.csproj.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | No
--------------------------------------------------------------------------------
/POCOGenerator/Entities/ConnectionItem.cs:
--------------------------------------------------------------------------------
1 | using System.Data.SqlClient;
2 |
3 |
4 | namespace POCOGenerator.Entities
5 | {
6 | public class ConnectionItem
7 | {
8 | public string ConnectionString { get; set; }
9 | public string DisplayName
10 | {
11 | get
12 | {
13 | var builder = new SqlConnectionStringBuilder(ConnectionString);
14 | return $"{builder.InitialCatalog} [{builder.DataSource}]";
15 | }
16 | }
17 |
18 | public ConnectionItem(string connectionString)
19 | {
20 | ConnectionString = connectionString;
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/POCOGenerator/Entities/Settings.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 |
3 |
4 | namespace POCOGenerator.Entities
5 | {
6 | public class Settings
7 | {
8 | public List ConnectionStrings { get; set; }
9 | public string SelectedConnection { get; set; }
10 | public string SqlView { get; set; }
11 | public string SqlProcedure { get; set; }
12 |
13 | public Settings()
14 | {
15 | ConnectionStrings = new List();
16 | SelectedConnection = null;
17 | SqlView = "SELECT * FROM ViewName";
18 | SqlProcedure = "EXEC StoredProcedure @parameter1=value1, @parameter2=value2, ... [AS Result1, Result2, ...]";
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/POCOGenerator/Properties/DataSources/POCOGenerator.Entities.SqlColumn.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | POCOGenerator.Entities.SqlColumn, POCOGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/POCOGenerator/Properties/DataSources/POCOGenerator.Entities.ResultItem.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | POCOGenerator.Entities.ResultItem, POCOGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/POCOGenerator/Properties/DataSources/POCOGenerator.Entities.ConnectionItem.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | POCOGenerator.Entities.ConnectionItem, POCOGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/POCOGenerator/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 |
3 | [assembly: AssemblyTitle("POCOGenerator")]
4 | [assembly: AssemblyDescription("Generate C# POCO classes from SQL data")]
5 | [assembly: AssemblyConfiguration("")]
6 | [assembly: AssemblyCompany("")]
7 | [assembly: AssemblyProduct("POCOGenerator")]
8 | [assembly: AssemblyCopyright("Jakob Lithner")]
9 | [assembly: AssemblyTrademark("")]
10 | [assembly: AssemblyCulture("")]
11 |
12 | [assembly: AssemblyVersion("1.1.0.0")]
13 | [assembly: AssemblyFileVersion("1.1.0.0")]
14 |
15 |
16 | // VERSION HISTORY
17 | //
18 | // Number Description
19 | //==================================================
20 | // 1.1 Adjusted label anchoring
21 | // 1.0 First numbered version
--------------------------------------------------------------------------------
/POCOGenerator/DomainServices/SettingsHandler.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Reflection;
3 | using System.Xml.Serialization;
4 | using POCOGenerator.Entities;
5 |
6 |
7 | namespace POCOGenerator.DomainServices
8 | {
9 | public static class SettingsHandler
10 | {
11 | private static readonly string FileName = $"{Assembly.GetExecutingAssembly().GetName().Name}.Settings.xml";
12 | private static readonly XmlSerializer Serializer = new XmlSerializer(typeof (Settings));
13 |
14 | public static Settings Get()
15 | {
16 | if (!File.Exists(FileName))
17 | {
18 | return new Settings();
19 | }
20 | using (var file = new StreamReader(FileName))
21 | {
22 | return (Settings) Serializer.Deserialize(file);
23 | }
24 | }
25 |
26 | public static void Save(Settings settings)
27 | {
28 | using (var file = new StreamWriter(FileName))
29 | {
30 | Serializer.Serialize(file, settings);
31 | file.Close();
32 | }
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/POCOGenerator/Controls/ResultContent.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 | using POCOGenerator.Entities;
3 |
4 |
5 | namespace POCOGenerator.Controls
6 | {
7 | public partial class ResultContent : UserControl
8 | {
9 | public ResultContent()
10 | {
11 | InitializeComponent();
12 | }
13 |
14 | public void Initiate(ResultItem resultItem)
15 | {
16 | sqlColumnBindingSource.DataSource = resultItem.SqlColumns;
17 | grdData.DataSource = resultItem.DataTable;
18 | txtCode.Text = resultItem.Code;
19 | }
20 |
21 | private void txtCode_KeyDown(object sender, KeyEventArgs e)
22 | {
23 | if (e.Control && e.KeyCode == Keys.A)
24 | {
25 | txtCode.SelectAll();
26 | }
27 | }
28 |
29 | private void grdData_DataError(object sender, DataGridViewDataErrorEventArgs e)
30 | {
31 | // There might be errors when a column has binary data.
32 | // This often happens for MigrationTables.
33 | // For this purpose we can safely suppress the errors.
34 | e.Cancel=true;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/POCOGenerator/POCOGenerator.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.31101.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "POCOGenerator", "POCOGenerator.csproj", "{B8201322-852D-4DEA-A39F-FCF8776F00D0}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B8201322-852D-4DEA-A39F-FCF8776F00D0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B8201322-852D-4DEA-A39F-FCF8776F00D0}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B8201322-852D-4DEA-A39F-FCF8776F00D0}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B8201322-852D-4DEA-A39F-FCF8776F00D0}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/POCOGenerator/Entities/SqlColumn.cs:
--------------------------------------------------------------------------------
1 | namespace POCOGenerator.Entities
2 | {
3 | public class SqlColumn
4 | {
5 | public string ColumnName { get; set; }
6 | public string BaseColumnName { get; set; }
7 | public string BaseTableName { get; set; }
8 | public string DataType { get; set; }
9 | public string ProviderSpecificDataType { get; set; }
10 | public string DataTypeName { get; set; }
11 |
12 | public int ColumnOrdinal { get; set; }
13 | public int ColumnSize { get; set; }
14 | public int NumericPrecision { get; set; }
15 | public int NumericScale { get; set; }
16 |
17 | public int ProviderType { get; set; }
18 | public int NonVersionedProviderType { get; set; }
19 |
20 | public bool IsUnique { get; set; }
21 | public bool IsColumnSet { get; set; }
22 | public bool AllowDBNull { get; set; }
23 | public bool IsKey { get; set; }
24 | public bool IsIdentity { get; set; }
25 | public bool IsAutoIncrement { get; set; }
26 | public bool IsRowVersion { get; set; }
27 | public bool IsLong { get; set; }
28 | public bool IsReadOnly { get; set; }
29 |
30 | }
31 | }
--------------------------------------------------------------------------------
/POCOGenerator/Extenders/StringExtender.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 |
4 | namespace POCOGenerator.Extenders
5 | {
6 | public static class StringExtender
7 | {
8 | public static string ToUpperFirst(this string value)
9 | {
10 | if (string.IsNullOrEmpty(value))
11 | return string.Empty;
12 | var a = value.ToCharArray();
13 | a[0] = char.ToUpper(a[0]);
14 | return new string(a);
15 | }
16 |
17 | ///
18 | /// Simple extension just to make code cleaner to read.
19 | ///
20 | public static bool IsNullOrEmpty(this string value)
21 | {
22 | return string.IsNullOrEmpty(value);
23 | }
24 |
25 | ///
26 | /// Simple extension just to make code cleaner to read.
27 | ///
28 | public static bool IsSpecified(this string value)
29 | {
30 | return !string.IsNullOrEmpty(value);
31 | }
32 |
33 | ///
34 | /// Parse string into specified enum type and make sure it matches a valid enum value.
35 | ///
36 | public static T ToEnum(this string value)
37 | {
38 | if (!Enum.IsDefined(typeof(T), value))
39 | throw new Exception(string.Format("String value='{0}' can not be interpreted as valid enum of type {1}", value, typeof(T).Name));
40 |
41 | return (T)Enum.Parse(typeof(T), value);
42 | }
43 | }
44 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # POCOGenerator
2 | 
3 |
4 | ## Background
5 | Often I find myself in situations where I nedd to handle data stored in existing database. To do this I need to create code classes that correspond to this data. Sometimes I use Entity Framework "Code First". Other times I use Dapper. The need is the same. It is boring (and error prone!) to manually copy columns to class properties and set correct data types. That's where this tool fits in. I just point to the database, select a table and the class is generated! In some cases a view or stored procedure is more adequate, so I added that as alternative approach. If you have the same need, feel free to just copy the solution or extend it for your needs.
6 |
7 | ## Features
8 | - You can use any SQL Server Database.
9 | - The source can be a table, view or stored procedure
10 | - Table names are automatically detected
11 | - Stored procedures can return multiple resultsets
12 | - Resulting class will have properties with identical names and corresponding C# data types
13 | - Class name will be taken from table or view (for procedures you have the possibility to add custom names in a provided "AS" syntax)
14 | - It is easy to add/edit/remove connections to the list
15 | - All settings will be saved during sessions
16 |
17 | ## Installation
18 | - Download source
19 | - Compile
20 | - All needed code is contained in one single EXE file: POCOGenerator.exe
21 | - Put file wherever you want and run it
22 | - Corresponding settings file will be generated in same directory and can be manually edited
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/POCOGenerator/Connection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Data.SqlClient;
3 | using System.Windows.Forms;
4 | using POCOGenerator.Extenders;
5 |
6 |
7 | namespace POCOGenerator
8 | {
9 | public partial class Connection : Form
10 | {
11 | public Connection()
12 | {
13 | InitializeComponent();
14 | }
15 |
16 |
17 | public string ConnectionString
18 | {
19 | get { return txtConnectionString.Text; }
20 | set { txtConnectionString.Text = value; }
21 | }
22 |
23 | public string DisplayName
24 | {
25 | get
26 | {
27 | var builder = new SqlConnectionStringBuilder(ConnectionString);
28 | return string.Format("{0} - {1}", builder.DataSource, builder.InitialCatalog);
29 | }
30 | }
31 |
32 |
33 | #region Event Handlers
34 |
35 | private void Connection_Load(object sender, EventArgs e)
36 | {
37 | if (txtConnectionString.Text.IsNullOrEmpty())
38 | {
39 | txtConnectionString.Text = @"Server=localhost; Database=; Trusted_Connection=True; User ID=; Password=;";
40 | }
41 | }
42 |
43 | private void Connection_Activated(object sender, EventArgs e)
44 | {
45 | btnCancel.Focus();
46 | }
47 |
48 | private void btnSave_Click(object sender, EventArgs e)
49 | {
50 | try
51 | {
52 | using (var con = new SqlConnection(txtConnectionString.Text))
53 | {
54 | con.Open();
55 | }
56 | DialogResult = DialogResult.OK;
57 | }
58 | catch (Exception ex)
59 | {
60 | MessageBox.Show("Failed to validate connection string", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error);
61 | }
62 | }
63 |
64 | #endregion
65 | }
66 | }
--------------------------------------------------------------------------------
/POCOGenerator/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
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 POCOGenerator.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("POCOGenerator.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and files generated by popular Visual Studio add-ons.
2 |
3 | ## Force include of result from this directory
4 | !/"Resulting EXE for direct installation"/*.*
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 |
17 | # Build results
18 | [Dd]ebug/
19 | [Dd]ebugPublic/
20 | [Rr]elease/
21 | [Rr]eleases/
22 | x64/
23 | x86/
24 | build/
25 | bld/
26 | [Bb]in/
27 | [Oo]bj/
28 | **/[Oo]bj/
29 |
30 |
31 | # Visual Studo 2015 cache/options directory
32 | .vs/
33 |
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 |
40 | # NUNIT
41 | *.VisualState.xml
42 | TestResult.xml
43 |
44 |
45 | # Build Results of an ATL Project
46 | [Dd]ebugPS/
47 | [Rr]eleasePS/
48 | dlldata.c
49 |
50 | *_i.c
51 | *_p.c
52 | *_i.h
53 | *.ilk
54 | *.meta
55 | *.obj
56 | *.pch
57 | *.pdb
58 | *.pgc
59 | *.pgd
60 | *.rsp
61 | *.sbr
62 | *.tlb
63 | *.tli
64 | *.tlh
65 | *.tmp
66 | *.tmp_proj
67 | *.log
68 | *.vspscc
69 | *.vssscc
70 | .builds
71 | *.pidb
72 | *.svclog
73 | *.scc
74 |
75 |
76 | # Visual Studio profiler
77 | *.psess
78 | *.vsp
79 | *.vspx
80 |
81 |
82 | # TFS 2012 Local Workspace
83 | $tf/
84 |
85 |
86 | # Guidance Automation Toolkit
87 | *.gpState
88 |
89 |
90 | # ReSharper is a .NET coding add-in
91 | _ReSharper*/
92 | *.[Rr]e[Ss]harper
93 | *.DotSettings.user
94 |
95 |
96 | # Web workbench (sass)
97 | .sass-cache/
98 |
99 |
100 | # Click-Once directory
101 | publish/
102 |
103 |
104 | # Publish Web Output
105 | *.[Pp]ublish.xml
106 | *.azurePubxml
107 | # TODO: Comment the next line if you want to checkin your web deploy settings
108 | # but database connection strings (with potential passwords) will be unencrypted
109 | *.pubxml
110 | *.publishproj
111 |
112 |
113 | # NuGet Packages
114 | *.nupkg
115 | # The packages folder can be ignored because of Package Restore
116 | **/packages/*
117 | # except build/, which is used as an MSBuild target.
118 | !**/packages/build/
119 | # Uncomment if necessary however generally it will be regenerated when needed
120 | #!**/packages/repositories.config
121 |
122 |
123 | # Windows Azure Build Output
124 | csx/
125 | *.build.csdef
126 |
127 |
128 | # Windows Store app package directory
129 | AppPackages/
130 |
131 |
132 | # Others
133 | *.[Cc]ache
134 | ClientBin/
135 | [Ss]tyle[Cc]op.*
136 | ~$*
137 | *~
138 | *.dbmdl
139 | *.dbproj.schemaview
140 | *.pfx
141 | *.publishsettings
142 | node_modules/
143 | bower_components/
144 |
145 |
146 | # RIA/Silverlight projects
147 | Generated_Code/
148 |
149 |
150 | # Backup & report files from converting an old project file to a newer Visual Studio version. Backup files are not needed, because we have git ;-)
151 | _UpgradeReport_Files/
152 | Backup*/
153 | UpgradeLog*.XML
154 | UpgradeLog*.htm
155 |
156 |
157 | # SQL Server files
158 | *.mdf
159 | *.ldf
160 |
161 |
162 | # Microsoft Fakes
163 | FakesAssemblies/
164 |
165 |
166 | # Node.js Tools for Visual Studio
167 | .ntvs_analysis.dat
168 |
--------------------------------------------------------------------------------
/POCOGenerator/Extenders/AssemblyExtender.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 | using System.Reflection;
4 |
5 |
6 | namespace POCOGenerator.Extenders
7 | {
8 | public static class AssemblyExtender
9 | {
10 | public static Version Version(this Assembly assembly)
11 | {
12 | return assembly.GetName().Version;
13 | }
14 |
15 | public static string DisplayVersion(this Assembly assembly)
16 | {
17 | var version = assembly.Version();
18 | return $"{version.Major}.{version.Minor} ({assembly.BuildDate().ToLocalTime().ToString("yyyy-MM-dd")})";
19 | }
20 |
21 | public static DateTime BuildDate(this Assembly assembly)
22 | {
23 | var filePath = assembly.Location;
24 | return GetTimestampFromLinker(filePath);
25 | }
26 |
27 | public static string Title(this Assembly assembly)
28 | {
29 | var attributes = assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
30 |
31 | // If there is at least one Title attribute
32 | if (attributes.Length > 0)
33 | {
34 | // Select the first one
35 | var attribute = (AssemblyTitleAttribute)attributes[0];
36 |
37 | // If it is not an empty string, return it
38 | if (!string.IsNullOrEmpty(attribute.Title))
39 | return attribute.Title;
40 | }
41 |
42 | // Fallback is to return assembly name
43 | return assembly.GetName().Name;
44 | }
45 |
46 | public static string Product(this Assembly assembly)
47 | {
48 | var attributes = assembly.GetCustomAttributes(typeof(AssemblyProductAttribute), false);
49 |
50 | // If there is at least one Title attribute
51 | if (attributes.Length > 0)
52 | {
53 | // Select the first one
54 | var attribute = (AssemblyProductAttribute)attributes[0];
55 | return attribute.Product;
56 | }
57 |
58 | // Fallback
59 | return string.Empty;
60 | }
61 |
62 | public static string Copyright(this Assembly assembly)
63 | {
64 | var attributes = assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
65 |
66 | // If there is at least one Title attribute
67 | if (attributes.Length > 0)
68 | {
69 | // Select the first one
70 | var attribute = (AssemblyCopyrightAttribute)attributes[0];
71 | return attribute.Copyright;
72 | }
73 |
74 | // Fallback
75 | return string.Empty;
76 | }
77 |
78 | ///
79 | /// Retrieves the linker timestamp from the file header.
80 | /// Code taken from here: http://www.codinghorror.com/blog/2005/04/determining-build-date-the-hard-way.html
81 | ///
82 | private static DateTime GetTimestampFromLinker(string filePath)
83 | {
84 | const int peHeaderOffset = 60;
85 | const int linkerTimestampOffset = 8;
86 | var baseDate = new DateTime(1970, 01, 01, 0, 0, 0);
87 |
88 | var b = new byte[2048];
89 | using (var s = new FileStream(filePath, FileMode.Open, FileAccess.Read))
90 | {
91 | s.Read(b, 0, 2048);
92 | }
93 |
94 | var timeInSeconds = BitConverter.ToInt32(b, BitConverter.ToInt32(b, peHeaderOffset) + linkerTimestampOffset);
95 | var dateTime = baseDate.AddSeconds(timeInSeconds);
96 | var dateTimeUtc = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
97 |
98 | return dateTimeUtc;
99 | }
100 |
101 | ///
102 | /// Retrieve the assembly build date.
103 | /// Note: This will only work for assemblies where the Build and Revision of the Version is auto generated!
104 | /// Example: [assembly: AssemblyVersion("4.2.*")]
105 | ///
106 | private static DateTime GetTimestampFromVersion(this Assembly assembly)
107 | {
108 | var version = assembly.Version();
109 | return new DateTime(2000, 1, 1).AddDays(version.Build).AddSeconds(version.Revision * 2);
110 | }
111 | }
112 | }
--------------------------------------------------------------------------------
/POCOGenerator/POCOGenerator.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {B8201322-852D-4DEA-A39F-FCF8776F00D0}
8 | WinExe
9 | Properties
10 | POCOGenerator
11 | POCOGenerator
12 | v4.8
13 | 512
14 |
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | AnyCPU
29 | pdbonly
30 | true
31 | bin\Release\
32 | TRACE
33 | prompt
34 | 4
35 |
36 |
37 | Resources\code.ico
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 | Form
54 |
55 |
56 | Connection.cs
57 |
58 |
59 | UserControl
60 |
61 |
62 | ResultContent.cs
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | Form
75 |
76 |
77 | Main.cs
78 |
79 |
80 |
81 |
82 | Connection.cs
83 |
84 |
85 | ResultContent.cs
86 |
87 |
88 | Main.cs
89 |
90 |
91 | ResXFileCodeGenerator
92 | Resources.Designer.cs
93 | Designer
94 |
95 |
96 | True
97 | Resources.resx
98 | True
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
121 |
--------------------------------------------------------------------------------
/POCOGenerator/Connection.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace POCOGenerator
2 | {
3 | partial class Connection
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Connection));
32 | this.txtConnectionString = new System.Windows.Forms.TextBox();
33 | this.btnCancel = new System.Windows.Forms.Button();
34 | this.btnSave = new System.Windows.Forms.Button();
35 | this.lblExplain = new System.Windows.Forms.Label();
36 | this.SuspendLayout();
37 | //
38 | // txtConnectionString
39 | //
40 | this.txtConnectionString.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
41 | | System.Windows.Forms.AnchorStyles.Left)
42 | | System.Windows.Forms.AnchorStyles.Right)));
43 | this.txtConnectionString.Font = new System.Drawing.Font("Courier New", 9.75F);
44 | this.txtConnectionString.ForeColor = System.Drawing.Color.Navy;
45 | this.txtConnectionString.Location = new System.Drawing.Point(22, 21);
46 | this.txtConnectionString.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
47 | this.txtConnectionString.Multiline = true;
48 | this.txtConnectionString.Name = "txtConnectionString";
49 | this.txtConnectionString.Size = new System.Drawing.Size(1823, 130);
50 | this.txtConnectionString.TabIndex = 7;
51 | //
52 | // btnCancel
53 | //
54 | this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
55 | this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
56 | this.btnCancel.Location = new System.Drawing.Point(1699, 348);
57 | this.btnCancel.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
58 | this.btnCancel.Name = "btnCancel";
59 | this.btnCancel.Size = new System.Drawing.Size(150, 44);
60 | this.btnCancel.TabIndex = 8;
61 | this.btnCancel.Text = "Cancel";
62 | this.btnCancel.UseVisualStyleBackColor = true;
63 | //
64 | // btnSave
65 | //
66 | this.btnSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
67 | this.btnSave.Location = new System.Drawing.Point(1537, 348);
68 | this.btnSave.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
69 | this.btnSave.Name = "btnSave";
70 | this.btnSave.Size = new System.Drawing.Size(150, 44);
71 | this.btnSave.TabIndex = 9;
72 | this.btnSave.Text = "OK";
73 | this.btnSave.UseVisualStyleBackColor = true;
74 | this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
75 | //
76 | // lblExplain
77 | //
78 | this.lblExplain.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
79 | | System.Windows.Forms.AnchorStyles.Right)));
80 | this.lblExplain.Location = new System.Drawing.Point(22, 179);
81 | this.lblExplain.Name = "lblExplain";
82 | this.lblExplain.Size = new System.Drawing.Size(1823, 163);
83 | this.lblExplain.TabIndex = 10;
84 | this.lblExplain.Text = resources.GetString("lblExplain.Text");
85 | //
86 | // Connection
87 | //
88 | this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
89 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
90 | this.CancelButton = this.btnCancel;
91 | this.ClientSize = new System.Drawing.Size(1871, 416);
92 | this.ControlBox = false;
93 | this.Controls.Add(this.lblExplain);
94 | this.Controls.Add(this.btnSave);
95 | this.Controls.Add(this.btnCancel);
96 | this.Controls.Add(this.txtConnectionString);
97 | this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
98 | this.MaximizeBox = false;
99 | this.MinimizeBox = false;
100 | this.Name = "Connection";
101 | this.ShowIcon = false;
102 | this.ShowInTaskbar = false;
103 | this.Text = "Connection";
104 | this.Activated += new System.EventHandler(this.Connection_Activated);
105 | this.Load += new System.EventHandler(this.Connection_Load);
106 | this.ResumeLayout(false);
107 | this.PerformLayout();
108 |
109 | }
110 |
111 | #endregion
112 |
113 | internal System.Windows.Forms.TextBox txtConnectionString;
114 | private System.Windows.Forms.Button btnCancel;
115 | private System.Windows.Forms.Button btnSave;
116 | private System.Windows.Forms.Label lblExplain;
117 | }
118 | }
--------------------------------------------------------------------------------
/POCOGenerator/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/POCOGenerator/Connection.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | Please specify your own connection string above.
122 | Normally you will use either Trusted_Connection or User ID and Password.
123 |
124 | Example:
125 | Server=xxx; Database=yyy; Trusted_Connection=True;
126 | Server=xxx; Database=yyy; User ID=uuu; Password=zzz;
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/POCOGenerator/Controls/ResultContent.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | True
122 |
123 |
124 | 17, 17
125 |
126 |
--------------------------------------------------------------------------------
/POCOGenerator/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Reflection;
6 | using System.Windows.Forms;
7 | using POCOGenerator.Controls;
8 | using POCOGenerator.DomainServices;
9 | using POCOGenerator.Entities;
10 | using POCOGenerator.Extenders;
11 |
12 |
13 | namespace POCOGenerator
14 | {
15 | public partial class Main : Form
16 | {
17 | private const int TopCount = 10;
18 |
19 |
20 | #region Properties
21 |
22 | private BindingList ConnectionItems
23 | {
24 | get { return (BindingList)connectionBindingSource.DataSource; }
25 | set { connectionBindingSource.DataSource = value; }
26 | }
27 |
28 | private string SelectedConnectionString
29 | {
30 | get
31 | {
32 | var connectionItem = (ConnectionItem)connectionBindingSource.Current;
33 | return connectionItem?.ConnectionString;
34 | }
35 | set
36 | {
37 | var connectionItem = connectionBindingSource.List.OfType().FirstOrDefault(c => c.ConnectionString == value);
38 | var i = connectionBindingSource.IndexOf(connectionItem);
39 | if (i >= 0)
40 | {
41 | connectionBindingSource.Position = i;
42 | }
43 | else if (connectionBindingSource.Count > 0)
44 | {
45 | cboConnection.SelectedIndex = 0;
46 | }
47 | }
48 | }
49 |
50 | #endregion
51 |
52 |
53 | public Main()
54 | {
55 | InitializeComponent();
56 | var assembly = Assembly.GetExecutingAssembly();
57 | lblVersion.Text = $"Version: {assembly.DisplayVersion()}, {assembly.Copyright()}";
58 | lnkSource.Links.Add(new LinkLabel.Link() { LinkData = "https://github.com/jaklithn/POCOGenerator" });
59 | tabResult.TabPages.Clear();
60 | }
61 |
62 |
63 | private void AddConnection()
64 | {
65 | var f = new Connection();
66 | var dialogResult = f.ShowDialog();
67 | if (dialogResult == DialogResult.OK)
68 | {
69 | ConnectionItems.Add(new ConnectionItem(f.ConnectionString));
70 | SelectedConnectionString = f.ConnectionString;
71 | SaveSettings();
72 | LoadTables();
73 | }
74 | }
75 |
76 | private void EditConnection()
77 | {
78 | var connection = ConnectionItems.FirstOrDefault(c => c.ConnectionString == cboConnection.SelectedValue.ToString());
79 | if (connection == null)
80 | {
81 | MessageBox.Show("There is no connection to edit", "Edit", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
82 | return;
83 | }
84 |
85 | var f = new Connection { ConnectionString = connection.ConnectionString };
86 | var dialogResult = f.ShowDialog();
87 | if (dialogResult == DialogResult.OK)
88 | {
89 | connection.ConnectionString = f.ConnectionString;
90 | // Reload datasource seems to be the easiest way to refresh data ...
91 | ConnectionItems = new BindingList(ConnectionItems.OrderBy(c => c.DisplayName).ToList());
92 | SelectedConnectionString = f.ConnectionString;
93 | SaveSettings();
94 | LoadTables();
95 | }
96 | }
97 |
98 | private void RemoveConnection()
99 | {
100 | var connection = ConnectionItems.FirstOrDefault(c => c.ConnectionString == cboConnection.SelectedValue.ToString());
101 | if (connection == null)
102 | {
103 | MessageBox.Show("There is no connection to remove", "Remove", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
104 | return;
105 | }
106 | ConnectionItems.Remove(connection);
107 | SaveSettings();
108 | LoadTables();
109 | }
110 |
111 | private void LoadTables()
112 | {
113 | cboTableName.DataSource = SelectedConnectionString.IsSpecified() ? SqlParser.GetTableNames(SelectedConnectionString) : null;
114 | }
115 |
116 | private void Generate(string sql)
117 | {
118 | try
119 | {
120 | Cursor = Cursors.WaitCursor;
121 |
122 | var adoHandler = new SqlParser(SelectedConnectionString, sql);
123 | resultItemBindingSource.DataSource = adoHandler.ResultItems;
124 |
125 | tabResult.TabPages.Clear();
126 | foreach (var resultItem in adoHandler.ResultItems)
127 | {
128 | var tabPage = new TabPage { Text = resultItem.EntityName, Margin = new Padding(0) };
129 | tabResult.TabPages.Add(tabPage);
130 |
131 | var content = new ResultContent { Dock = DockStyle.Fill };
132 | content.Initiate(resultItem);
133 | tabPage.Controls.Add(content);
134 | }
135 | }
136 | catch (Exception ex)
137 | {
138 | MessageBox.Show(ex.Message, "GenerateClass", MessageBoxButtons.OK, MessageBoxIcon.Error);
139 | }
140 | finally
141 | {
142 | Cursor = Cursors.Default;
143 | }
144 | }
145 |
146 | private void AdjustSql()
147 | {
148 | var sql = txtSqlView.Text.Trim();
149 | txtSqlView.Text = sql.Replace("SELECT *", string.Format("SELECT TOP {0} *", TopCount));
150 | }
151 |
152 | private void GetSettings()
153 | {
154 | var settings = SettingsHandler.Get();
155 | ConnectionItems = new BindingList(settings.ConnectionStrings.Select(x => new ConnectionItem(x)).OrderBy(c => c.DisplayName).ToList());
156 | if (ConnectionItems.Any(c => c.ConnectionString == settings.SelectedConnection))
157 | {
158 | SelectedConnectionString = settings.SelectedConnection;
159 | LoadTables();
160 | }
161 |
162 | txtSqlView.Text = settings.SqlView;
163 | txtSqlProcedure.Text = settings.SqlProcedure;
164 |
165 | if (Environment.UserName == "jal")
166 | {
167 | txtSqlProcedure.Text = "EXEC usp_ExtExportGetTasks @ServerId=0, @ExternalSystemId=2, @MaxProcessingTimeInMinutes=5 AS Task, Customer, Activity, Helper";
168 | }
169 | }
170 |
171 | private void SaveSettings()
172 | {
173 | var settings = new Settings
174 | {
175 | ConnectionStrings = ConnectionItems.Select(x => x.ConnectionString).ToList(),
176 | SelectedConnection = SelectedConnectionString,
177 | SqlView = txtSqlView.Text,
178 | SqlProcedure = txtSqlProcedure.Text
179 | };
180 | SettingsHandler.Save(settings);
181 | }
182 |
183 |
184 | #region Event Handlers
185 |
186 | private void Main_Load(object sender, EventArgs e)
187 | {
188 | GetSettings();
189 | }
190 |
191 | private void btnAdd_Click(object sender, EventArgs e)
192 | {
193 | AddConnection();
194 | }
195 |
196 | private void btnEdit_Click(object sender, EventArgs e)
197 | {
198 | EditConnection();
199 | }
200 |
201 | private void btnRemove_Click(object sender, EventArgs e)
202 | {
203 | RemoveConnection();
204 | }
205 |
206 | private void connectionBindingSource_CurrentChanged(object sender, EventArgs e)
207 | {
208 | LoadTables();
209 | }
210 |
211 | private void btnGenerateTable_Click(object sender, EventArgs e)
212 | {
213 | var sql = string.Format("SELECT TOP {0} * FROM {1}", TopCount, cboTableName.Text);
214 | SaveSettings();
215 | Generate(sql);
216 | }
217 |
218 | private void btnGenerateView_Click(object sender, EventArgs e)
219 | {
220 | SaveSettings();
221 | AdjustSql();
222 | Generate(txtSqlView.Text);
223 | }
224 |
225 | private void btnGenerate_Click(object sender, EventArgs e)
226 | {
227 | SaveSettings();
228 | Generate(txtSqlProcedure.Text);
229 | }
230 |
231 | private void lnkSource_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
232 | {
233 | Process.Start(e.Link.LinkData.ToString());
234 | }
235 |
236 | #endregion
237 | }
238 | }
--------------------------------------------------------------------------------
/POCOGenerator/DomainServices/SqlParser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Data;
4 | using System.Data.SqlClient;
5 | using System.Diagnostics;
6 | using System.Linq;
7 | using System.Text;
8 | using POCOGenerator.Entities;
9 |
10 |
11 | namespace POCOGenerator.DomainServices
12 | {
13 | public class SqlParser
14 | {
15 | public List ResultItems { get; private set; }
16 |
17 | public SqlParser(string connectionString, string sql)
18 | {
19 | // Parse possible entity names specified in the custom "AS" section
20 | var procedureEntityNames = string.Empty;
21 | var sqlUpper = sql.ToUpper().Trim();
22 | if (sqlUpper.StartsWith("EXEC"))
23 | {
24 | var posAs = sqlUpper.IndexOf(" AS ");
25 | if (posAs > 5)
26 | {
27 | procedureEntityNames = sql.Substring(posAs + 4);
28 | sql = sql.Substring(0, posAs);
29 | }
30 | }
31 |
32 | // Decorate table name with brackets
33 | var posFrom = sql.IndexOf(" FROM ");
34 | if (posFrom > 0)
35 | {
36 | var tableName = sql.Substring(posFrom + 6);
37 | tableName = tableName.Replace("[", "").Replace("]", "");
38 | var sections = tableName.Split(".".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
39 | var decoratedTable = "[" + string.Join("].[", sections) + "]";
40 | sql = sql.Substring(0, posFrom + 6) + decoratedTable;
41 | }
42 |
43 | ParseTables(connectionString, sql, procedureEntityNames);
44 | ParseColumns();
45 | GenerateCode();
46 | }
47 |
48 | public static List GetTableNames(string connectionString)
49 | {
50 | using (var con = new SqlConnection(connectionString))
51 | {
52 | con.Open();
53 | var tables = new List();
54 | var dt = con.GetSchema("Tables");
55 | foreach (DataRow row in dt.Rows)
56 | {
57 | var database = row[0].ToString();
58 | var schema = row[1].ToString();
59 | var name = row[2].ToString();
60 | var type = row[3].ToString();
61 | Debug.WriteLine("{0}, {1}, {2}, {3}", database, schema, name, type);
62 |
63 | if (type == "BASE TABLE" && name != "sysdiagrams")
64 | {
65 | var tableSpecifier = schema == "dbo" ? name : string.Format("{0}.{1}", schema, name);
66 | tables.Add(tableSpecifier);
67 | }
68 | }
69 | return tables.OrderBy(t => t).ToList();
70 | }
71 | }
72 |
73 | private void ParseTables(string connectionString, string sql, string procedureEntityNames)
74 | {
75 | using (var con = new SqlConnection(connectionString))
76 | {
77 | con.Open();
78 | using (var cmd = new SqlCommand())
79 | {
80 | cmd.Connection = con;
81 | cmd.CommandType = GetCommandType(sql);
82 | cmd.CommandText = GetCommandText(cmd.CommandType, sql);
83 | cmd.CommandTimeout = 60;
84 | if (cmd.CommandType == CommandType.StoredProcedure)
85 | cmd.Parameters.AddRange(GetParameters(sql));
86 |
87 | ResultItems = new List();
88 |
89 | // Retrieve data
90 | var content = new DataSet();
91 | using (var adapter = new SqlDataAdapter(cmd))
92 | {
93 | adapter.Fill(content);
94 | }
95 |
96 | // Loop through data tables and datareader in parallell adding data+schema
97 | using (var dr = cmd.ExecuteReader(CommandBehavior.Default))
98 | {
99 | for (var i = 0; i < content.Tables.Count; i++)
100 | {
101 | var table = content.Tables[i];
102 | var resultItem = new ResultItem { SchemaTable = dr.GetSchemaTable(), DataTable = table, EntityName = GetEntityName(sql, i, table.TableName, procedureEntityNames) };
103 | ResultItems.Add(resultItem);
104 | dr.NextResult();
105 | }
106 | }
107 | }
108 | }
109 | }
110 |
111 | private void ParseColumns()
112 | {
113 | foreach (var resultItem in ResultItems)
114 | {
115 | resultItem.SqlColumns = new List();
116 |
117 | var typeProperties = new[] { "DataType", "ProviderSpecificDataType" };
118 | var missingProperties = new HashSet();
119 |
120 | for (var rowIndex = 0; rowIndex < resultItem.SchemaTable.Rows.Count; rowIndex++)
121 | {
122 | var sqlColumn = new SqlColumn();
123 | for (var columnIndex = 0; columnIndex < resultItem.SchemaTable.Columns.Count; columnIndex++)
124 | {
125 | var propertyName = resultItem.SchemaTable.Columns[columnIndex].ColumnName;
126 | var value = resultItem.SchemaTable.Rows[rowIndex][columnIndex];
127 |
128 | if (typeProperties.Contains(propertyName))
129 | {
130 | value = ((Type)value).FullName;
131 | }
132 |
133 | var property = typeof(SqlColumn).GetProperty(propertyName);
134 | if (!Convert.IsDBNull(value) && property != null)
135 | {
136 | property.SetValue(sqlColumn, value, null);
137 | }
138 | else
139 | {
140 | missingProperties.Add(propertyName);
141 | }
142 | }
143 |
144 | // Adjust
145 |
146 | var decimalTypes = new[] { "real", "float", "decimal", "money", "smallmoney" };
147 | if (decimalTypes.Contains(sqlColumn.DataTypeName))
148 | {
149 | sqlColumn.NumericScale = 0;
150 | sqlColumn.NumericPrecision = 0;
151 | }
152 | resultItem.SqlColumns.Add(sqlColumn);
153 | }
154 |
155 | Debug.WriteLine(string.Format("MissingProperties: {0}", string.Join(", ", missingProperties)));
156 | }
157 | }
158 |
159 | private void GenerateCode()
160 | {
161 | foreach (var resultItem in ResultItems)
162 | {
163 | var sb = new StringBuilder();
164 | sb.AppendLine(string.Format("public class {0}", resultItem.EntityName));
165 | sb.AppendLine("{");
166 |
167 | foreach (var sqlColumn in resultItem.SqlColumns)
168 | {
169 | sb.AppendLine($" public {GetNullableDataType(sqlColumn)} {sqlColumn.ColumnName} {{ get; set; }}");
170 | }
171 |
172 | sb.AppendLine("}");
173 | sb.AppendLine("");
174 |
175 | resultItem.Code = sb.ToString();
176 | }
177 | }
178 |
179 | private static string GetNullableDataType(SqlColumn sqlColumn)
180 | {
181 | var nonNullableTypes = new[] { "string", "object", "Guid", "DataTable" };
182 | var dataType = GetDataType(sqlColumn);
183 | var addNullability = sqlColumn.AllowDBNull && !nonNullableTypes.Contains(dataType);
184 | return addNullability ? dataType + "?" : dataType;
185 | }
186 |
187 | private static string GetDataType(SqlColumn sqlColumn)
188 | {
189 | switch (sqlColumn.DataTypeName)
190 | {
191 | case "bit":
192 | return "bool";
193 |
194 | case "tinyint":
195 | return "byte";
196 | case "smallint":
197 | return "short";
198 | case "int":
199 | return "int";
200 | case "bigint":
201 | return "long";
202 |
203 | case "real":
204 | return "float";
205 | case "float":
206 | return "double";
207 | case "decimal":
208 | case "money":
209 | case "smallmoney":
210 | return "decimal";
211 |
212 | case "time":
213 | return "TimeSpan";
214 | case "date":
215 | case "datetime":
216 | case "datetime2":
217 | case "smalldatetime":
218 | return "DateTime";
219 | case "datetimeoffset":
220 | return "DateTimeOffset";
221 |
222 | case "char":
223 | case "varchar":
224 | case "nchar":
225 | case "nvarchar":
226 | case "text":
227 | case "ntext":
228 | case "xml":
229 | return "string";
230 |
231 | case "binary":
232 | case "image":
233 | case "varbinary":
234 | case "timestamp":
235 | return "byte[]";
236 |
237 | case "uniqueidentifier":
238 | return "Guid";
239 |
240 | case "variant":
241 | case "Udt":
242 | return "object";
243 |
244 | case "Structured":
245 | return "DataTable";
246 |
247 | case "geography":
248 | return "geography";
249 |
250 | default:
251 | // Fallback to be manually handled by user
252 | return sqlColumn.DataTypeName;
253 | }
254 | }
255 |
256 | private static string GetCommandText(CommandType commandType, string sql)
257 | {
258 | switch (commandType)
259 | {
260 | case CommandType.Text:
261 | return sql;
262 |
263 | case CommandType.StoredProcedure:
264 | var sections = sql.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
265 | if (sections.Count() >= 2 && sections[0].ToUpper() == "EXEC")
266 | return sections[1];
267 | throw new Exception("Could not parse Name of StoredProcedure");
268 |
269 | default:
270 | throw new Exception(string.Format("CommandType={0} is not handled", commandType));
271 | }
272 | }
273 |
274 | private static CommandType GetCommandType(string sql)
275 | {
276 | return sql.ToUpper().Trim().StartsWith("SELECT") ? CommandType.Text : CommandType.StoredProcedure;
277 | }
278 |
279 | private static string GetEntityName(string sql, int index, string tableName, string procedureEntityNames)
280 | {
281 | var commandType = GetCommandType(sql);
282 | switch (commandType)
283 | {
284 | case CommandType.Text:
285 | var sections = sql.Split("[] ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
286 | return sections[sections.Length - 1];
287 |
288 | case CommandType.StoredProcedure:
289 | if (!string.IsNullOrEmpty(procedureEntityNames))
290 | {
291 | var names = procedureEntityNames.Split(",. ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
292 | if (index < names.Length)
293 | return names[index];
294 | }
295 | break;
296 | }
297 | return tableName;
298 | }
299 |
300 | private static SqlParameter[] GetParameters(string sql)
301 | {
302 | var parameters = new List();
303 | var pos = sql.IndexOf('@');
304 | if (pos > 0)
305 | {
306 | sql = sql.Substring(pos);
307 | var pairs = sql.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
308 | foreach (var pair in pairs)
309 | {
310 | var values = pair.Split("= ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
311 | parameters.Add(new SqlParameter(values[0], values[1]));
312 | }
313 | }
314 | return parameters.ToArray();
315 | }
316 |
317 | }
318 | }
--------------------------------------------------------------------------------
/POCOGenerator/Main.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace POCOGenerator
2 | {
3 | partial class Main
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows Form Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Main));
33 | this.txtSqlView = new System.Windows.Forms.TextBox();
34 | this.btnGenerateProc = new System.Windows.Forms.Button();
35 | this.tabResult = new System.Windows.Forms.TabControl();
36 | this.tabPage1 = new System.Windows.Forms.TabPage();
37 | this.tabPage2 = new System.Windows.Forms.TabPage();
38 | this.txtSqlProcedure = new System.Windows.Forms.TextBox();
39 | this.btnGenerateTable = new System.Windows.Forms.Button();
40 | this.btnGenerateView = new System.Windows.Forms.Button();
41 | this.cboTableName = new System.Windows.Forms.ComboBox();
42 | this.cboConnection = new System.Windows.Forms.ComboBox();
43 | this.connectionBindingSource = new System.Windows.Forms.BindingSource(this.components);
44 | this.lblConnection = new System.Windows.Forms.Label();
45 | this.btnAdd = new System.Windows.Forms.Button();
46 | this.btnEdit = new System.Windows.Forms.Button();
47 | this.btnRemove = new System.Windows.Forms.Button();
48 | this.sqlColumnBindingSource = new System.Windows.Forms.BindingSource(this.components);
49 | this.resultItemBindingSource = new System.Windows.Forms.BindingSource(this.components);
50 | this.label1 = new System.Windows.Forms.Label();
51 | this.lblVersion = new System.Windows.Forms.Label();
52 | this.lnkSource = new System.Windows.Forms.LinkLabel();
53 | this.MyToolTip = new System.Windows.Forms.ToolTip(this.components);
54 | this.tabResult.SuspendLayout();
55 | ((System.ComponentModel.ISupportInitialize)(this.connectionBindingSource)).BeginInit();
56 | ((System.ComponentModel.ISupportInitialize)(this.sqlColumnBindingSource)).BeginInit();
57 | ((System.ComponentModel.ISupportInitialize)(this.resultItemBindingSource)).BeginInit();
58 | this.SuspendLayout();
59 | //
60 | // txtSqlView
61 | //
62 | this.txtSqlView.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
63 | | System.Windows.Forms.AnchorStyles.Right)));
64 | this.txtSqlView.Font = new System.Drawing.Font("Courier New", 9.75F);
65 | this.txtSqlView.ForeColor = System.Drawing.Color.Navy;
66 | this.txtSqlView.Location = new System.Drawing.Point(19, 47);
67 | this.txtSqlView.Margin = new System.Windows.Forms.Padding(2);
68 | this.txtSqlView.Multiline = true;
69 | this.txtSqlView.Name = "txtSqlView";
70 | this.txtSqlView.Size = new System.Drawing.Size(1175, 24);
71 | this.txtSqlView.TabIndex = 18;
72 | //
73 | // btnGenerateProc
74 | //
75 | this.btnGenerateProc.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
76 | this.btnGenerateProc.Location = new System.Drawing.Point(1207, 81);
77 | this.btnGenerateProc.Margin = new System.Windows.Forms.Padding(2);
78 | this.btnGenerateProc.Name = "btnGenerateProc";
79 | this.btnGenerateProc.Size = new System.Drawing.Size(188, 24);
80 | this.btnGenerateProc.TabIndex = 23;
81 | this.btnGenerateProc.Text = "Generate from Procedure";
82 | this.btnGenerateProc.UseVisualStyleBackColor = true;
83 | this.btnGenerateProc.Click += new System.EventHandler(this.btnGenerate_Click);
84 | //
85 | // tabResult
86 | //
87 | this.tabResult.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
88 | | System.Windows.Forms.AnchorStyles.Left)
89 | | System.Windows.Forms.AnchorStyles.Right)));
90 | this.tabResult.Controls.Add(this.tabPage1);
91 | this.tabResult.Controls.Add(this.tabPage2);
92 | this.tabResult.Location = new System.Drawing.Point(11, 128);
93 | this.tabResult.Name = "tabResult";
94 | this.tabResult.Padding = new System.Drawing.Point(20, 4);
95 | this.tabResult.SelectedIndex = 0;
96 | this.tabResult.Size = new System.Drawing.Size(1384, 624);
97 | this.tabResult.TabIndex = 28;
98 | //
99 | // tabPage1
100 | //
101 | this.tabPage1.Location = new System.Drawing.Point(4, 24);
102 | this.tabPage1.Name = "tabPage1";
103 | this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
104 | this.tabPage1.Size = new System.Drawing.Size(1376, 596);
105 | this.tabPage1.TabIndex = 0;
106 | this.tabPage1.Text = "tabPage1";
107 | this.tabPage1.UseVisualStyleBackColor = true;
108 | //
109 | // tabPage2
110 | //
111 | this.tabPage2.Location = new System.Drawing.Point(4, 24);
112 | this.tabPage2.Name = "tabPage2";
113 | this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
114 | this.tabPage2.Size = new System.Drawing.Size(1376, 596);
115 | this.tabPage2.TabIndex = 1;
116 | this.tabPage2.Text = "tabPage2";
117 | this.tabPage2.UseVisualStyleBackColor = true;
118 | //
119 | // txtSqlProcedure
120 | //
121 | this.txtSqlProcedure.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
122 | | System.Windows.Forms.AnchorStyles.Right)));
123 | this.txtSqlProcedure.Font = new System.Drawing.Font("Courier New", 9.75F);
124 | this.txtSqlProcedure.ForeColor = System.Drawing.Color.Navy;
125 | this.txtSqlProcedure.Location = new System.Drawing.Point(19, 81);
126 | this.txtSqlProcedure.Margin = new System.Windows.Forms.Padding(2);
127 | this.txtSqlProcedure.Multiline = true;
128 | this.txtSqlProcedure.Name = "txtSqlProcedure";
129 | this.txtSqlProcedure.Size = new System.Drawing.Size(1175, 24);
130 | this.txtSqlProcedure.TabIndex = 31;
131 | //
132 | // btnGenerateTable
133 | //
134 | this.btnGenerateTable.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
135 | this.btnGenerateTable.Location = new System.Drawing.Point(1207, 14);
136 | this.btnGenerateTable.Margin = new System.Windows.Forms.Padding(2);
137 | this.btnGenerateTable.Name = "btnGenerateTable";
138 | this.btnGenerateTable.Size = new System.Drawing.Size(188, 24);
139 | this.btnGenerateTable.TabIndex = 32;
140 | this.btnGenerateTable.Text = "Generate from Table";
141 | this.btnGenerateTable.UseVisualStyleBackColor = true;
142 | this.btnGenerateTable.Click += new System.EventHandler(this.btnGenerateTable_Click);
143 | //
144 | // btnGenerateView
145 | //
146 | this.btnGenerateView.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
147 | this.btnGenerateView.Location = new System.Drawing.Point(1207, 47);
148 | this.btnGenerateView.Margin = new System.Windows.Forms.Padding(2);
149 | this.btnGenerateView.Name = "btnGenerateView";
150 | this.btnGenerateView.Size = new System.Drawing.Size(188, 24);
151 | this.btnGenerateView.TabIndex = 33;
152 | this.btnGenerateView.Text = "Generate from View";
153 | this.btnGenerateView.UseVisualStyleBackColor = true;
154 | this.btnGenerateView.Click += new System.EventHandler(this.btnGenerateView_Click);
155 | //
156 | // cboTableName
157 | //
158 | this.cboTableName.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
159 | this.cboTableName.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
160 | this.cboTableName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
161 | this.cboTableName.ForeColor = System.Drawing.SystemColors.ControlText;
162 | this.cboTableName.FormattingEnabled = true;
163 | this.cboTableName.Location = new System.Drawing.Point(966, 16);
164 | this.cboTableName.MaxDropDownItems = 50;
165 | this.cboTableName.Name = "cboTableName";
166 | this.cboTableName.Size = new System.Drawing.Size(228, 21);
167 | this.cboTableName.TabIndex = 34;
168 | //
169 | // cboConnection
170 | //
171 | this.cboConnection.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
172 | | System.Windows.Forms.AnchorStyles.Right)));
173 | this.cboConnection.DataSource = this.connectionBindingSource;
174 | this.cboConnection.DisplayMember = "DisplayName";
175 | this.cboConnection.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
176 | this.cboConnection.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F);
177 | this.cboConnection.ForeColor = System.Drawing.SystemColors.ControlText;
178 | this.cboConnection.Location = new System.Drawing.Point(114, 16);
179 | this.cboConnection.Name = "cboConnection";
180 | this.cboConnection.Size = new System.Drawing.Size(550, 21);
181 | this.cboConnection.TabIndex = 36;
182 | this.cboConnection.ValueMember = "ConnectionString";
183 | //
184 | // connectionBindingSource
185 | //
186 | this.connectionBindingSource.DataSource = typeof(POCOGenerator.Entities.ConnectionItem);
187 | this.connectionBindingSource.CurrentChanged += new System.EventHandler(this.connectionBindingSource_CurrentChanged);
188 | //
189 | // lblConnection
190 | //
191 | this.lblConnection.AutoSize = true;
192 | this.lblConnection.Location = new System.Drawing.Point(16, 20);
193 | this.lblConnection.Name = "lblConnection";
194 | this.lblConnection.Size = new System.Drawing.Size(92, 13);
195 | this.lblConnection.TabIndex = 37;
196 | this.lblConnection.Text = "Connection string:";
197 | this.lblConnection.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
198 | //
199 | // btnAdd
200 | //
201 | this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
202 | this.btnAdd.Location = new System.Drawing.Point(678, 14);
203 | this.btnAdd.Margin = new System.Windows.Forms.Padding(2);
204 | this.btnAdd.Name = "btnAdd";
205 | this.btnAdd.Size = new System.Drawing.Size(60, 24);
206 | this.btnAdd.TabIndex = 38;
207 | this.btnAdd.Text = "Add";
208 | this.btnAdd.UseVisualStyleBackColor = true;
209 | this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
210 | //
211 | // btnEdit
212 | //
213 | this.btnEdit.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
214 | this.btnEdit.Location = new System.Drawing.Point(742, 14);
215 | this.btnEdit.Margin = new System.Windows.Forms.Padding(2);
216 | this.btnEdit.Name = "btnEdit";
217 | this.btnEdit.Size = new System.Drawing.Size(60, 24);
218 | this.btnEdit.TabIndex = 39;
219 | this.btnEdit.Text = "Edit";
220 | this.btnEdit.UseVisualStyleBackColor = true;
221 | this.btnEdit.Click += new System.EventHandler(this.btnEdit_Click);
222 | //
223 | // btnRemove
224 | //
225 | this.btnRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
226 | this.btnRemove.Location = new System.Drawing.Point(806, 14);
227 | this.btnRemove.Margin = new System.Windows.Forms.Padding(2);
228 | this.btnRemove.Name = "btnRemove";
229 | this.btnRemove.Size = new System.Drawing.Size(60, 24);
230 | this.btnRemove.TabIndex = 40;
231 | this.btnRemove.Text = "Remove";
232 | this.btnRemove.UseVisualStyleBackColor = true;
233 | this.btnRemove.Click += new System.EventHandler(this.btnRemove_Click);
234 | //
235 | // sqlColumnBindingSource
236 | //
237 | this.sqlColumnBindingSource.DataSource = typeof(POCOGenerator.Entities.SqlColumn);
238 | //
239 | // resultItemBindingSource
240 | //
241 | this.resultItemBindingSource.DataSource = typeof(POCOGenerator.Entities.ResultItem);
242 | //
243 | // label1
244 | //
245 | this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
246 | this.label1.AutoSize = true;
247 | this.label1.Location = new System.Drawing.Point(894, 20);
248 | this.label1.Name = "label1";
249 | this.label1.Size = new System.Drawing.Size(66, 13);
250 | this.label1.TabIndex = 41;
251 | this.label1.Text = "Table name:";
252 | this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
253 | //
254 | // lblVersion
255 | //
256 | this.lblVersion.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
257 | this.lblVersion.ForeColor = System.Drawing.Color.Navy;
258 | this.lblVersion.Location = new System.Drawing.Point(11, 756);
259 | this.lblVersion.Name = "lblVersion";
260 | this.lblVersion.Size = new System.Drawing.Size(307, 21);
261 | this.lblVersion.TabIndex = 42;
262 | this.lblVersion.Text = "Version 1.0, Jakob Lithner";
263 | this.lblVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
264 | //
265 | // lnkSource
266 | //
267 | this.lnkSource.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
268 | this.lnkSource.AutoSize = true;
269 | this.lnkSource.Location = new System.Drawing.Point(1248, 760);
270 | this.lnkSource.Name = "lnkSource";
271 | this.lnkSource.Size = new System.Drawing.Size(147, 13);
272 | this.lnkSource.TabIndex = 43;
273 | this.lnkSource.TabStop = true;
274 | this.lnkSource.Text = "OpenSource stored at GitHub";
275 | this.lnkSource.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
276 | this.MyToolTip.SetToolTip(this.lnkSource, "Find source in GitHub repository");
277 | this.lnkSource.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.lnkSource_LinkClicked);
278 | //
279 | // Main
280 | //
281 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
282 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
283 | this.BackColor = System.Drawing.Color.AliceBlue;
284 | this.ClientSize = new System.Drawing.Size(1406, 780);
285 | this.Controls.Add(this.lnkSource);
286 | this.Controls.Add(this.lblVersion);
287 | this.Controls.Add(this.label1);
288 | this.Controls.Add(this.btnRemove);
289 | this.Controls.Add(this.btnEdit);
290 | this.Controls.Add(this.btnAdd);
291 | this.Controls.Add(this.cboConnection);
292 | this.Controls.Add(this.lblConnection);
293 | this.Controls.Add(this.cboTableName);
294 | this.Controls.Add(this.btnGenerateView);
295 | this.Controls.Add(this.btnGenerateTable);
296 | this.Controls.Add(this.txtSqlProcedure);
297 | this.Controls.Add(this.btnGenerateProc);
298 | this.Controls.Add(this.tabResult);
299 | this.Controls.Add(this.txtSqlView);
300 | this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
301 | this.Name = "Main";
302 | this.Text = "Generate C# POCO class from SQL Server";
303 | this.Load += new System.EventHandler(this.Main_Load);
304 | this.tabResult.ResumeLayout(false);
305 | ((System.ComponentModel.ISupportInitialize)(this.connectionBindingSource)).EndInit();
306 | ((System.ComponentModel.ISupportInitialize)(this.sqlColumnBindingSource)).EndInit();
307 | ((System.ComponentModel.ISupportInitialize)(this.resultItemBindingSource)).EndInit();
308 | this.ResumeLayout(false);
309 | this.PerformLayout();
310 |
311 | }
312 |
313 | #endregion
314 |
315 | internal System.Windows.Forms.TextBox txtSqlView;
316 | internal System.Windows.Forms.Button btnGenerateProc;
317 | private System.Windows.Forms.BindingSource sqlColumnBindingSource;
318 | private System.Windows.Forms.BindingSource resultItemBindingSource;
319 | private System.Windows.Forms.TabControl tabResult;
320 | private System.Windows.Forms.TabPage tabPage1;
321 | private System.Windows.Forms.TabPage tabPage2;
322 | internal System.Windows.Forms.TextBox txtSqlProcedure;
323 | internal System.Windows.Forms.Button btnGenerateTable;
324 | internal System.Windows.Forms.Button btnGenerateView;
325 | private System.Windows.Forms.ComboBox cboTableName;
326 | private System.Windows.Forms.ComboBox cboConnection;
327 | private System.Windows.Forms.Label lblConnection;
328 | internal System.Windows.Forms.Button btnAdd;
329 | internal System.Windows.Forms.Button btnEdit;
330 | internal System.Windows.Forms.Button btnRemove;
331 | private System.Windows.Forms.BindingSource connectionBindingSource;
332 | private System.Windows.Forms.Label label1;
333 | private System.Windows.Forms.Label lblVersion;
334 | private System.Windows.Forms.LinkLabel lnkSource;
335 | private System.Windows.Forms.ToolTip MyToolTip;
336 | }
337 | }
338 |
339 |
--------------------------------------------------------------------------------
/POCOGenerator/Controls/ResultContent.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace POCOGenerator.Controls
2 | {
3 | partial class ResultContent
4 | {
5 | ///
6 | /// Required designer variable.
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// Clean up any resources being used.
12 | ///
13 | /// true if managed resources should be disposed; otherwise, false.
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Component Designer generated code
24 |
25 | ///
26 | /// Required method for Designer support - do not modify
27 | /// the contents of this method with the code editor.
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | this.tabTable = new System.Windows.Forms.TabControl();
33 | this.tabData = new System.Windows.Forms.TabPage();
34 | this.grdData = new System.Windows.Forms.DataGridView();
35 | this.tabSchema = new System.Windows.Forms.TabPage();
36 | this.grdSchema = new System.Windows.Forms.DataGridView();
37 | this.columnNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
38 | this.dataTypeNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
39 | this.dataTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
40 | this.columnSizeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
41 | this.NumericScale = new System.Windows.Forms.DataGridViewTextBoxColumn();
42 | this.numericPrecisionDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
43 | this.allowDBNullDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
44 | this.isKeyDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
45 | this.isIdentityDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
46 | this.isAutoIncrementDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
47 | this.sqlColumnBindingSource = new System.Windows.Forms.BindingSource(this.components);
48 | this.tableResult = new System.Windows.Forms.TableLayoutPanel();
49 | this.txtCode = new System.Windows.Forms.TextBox();
50 | this.baseColumnNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
51 | this.baseTableNameDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
52 | this.providerSpecificDataTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
53 | this.columnOrdinalDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
54 | this.numericScaleDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
55 | this.providerTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
56 | this.nonVersionedProviderTypeDataGridViewTextBoxColumn = new System.Windows.Forms.DataGridViewTextBoxColumn();
57 | this.isUniqueDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
58 | this.isColumnSetDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
59 | this.isRowVersionDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
60 | this.isLongDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
61 | this.isReadOnlyDataGridViewCheckBoxColumn = new System.Windows.Forms.DataGridViewCheckBoxColumn();
62 | this.tabTable.SuspendLayout();
63 | this.tabData.SuspendLayout();
64 | ((System.ComponentModel.ISupportInitialize)(this.grdData)).BeginInit();
65 | this.tabSchema.SuspendLayout();
66 | ((System.ComponentModel.ISupportInitialize)(this.grdSchema)).BeginInit();
67 | ((System.ComponentModel.ISupportInitialize)(this.sqlColumnBindingSource)).BeginInit();
68 | this.tableResult.SuspendLayout();
69 | this.SuspendLayout();
70 | //
71 | // tabTable
72 | //
73 | this.tabTable.Alignment = System.Windows.Forms.TabAlignment.Left;
74 | this.tabTable.Controls.Add(this.tabData);
75 | this.tabTable.Controls.Add(this.tabSchema);
76 | this.tabTable.Dock = System.Windows.Forms.DockStyle.Fill;
77 | this.tabTable.Font = new System.Drawing.Font("Arial", 9F);
78 | this.tabTable.Location = new System.Drawing.Point(3, 403);
79 | this.tabTable.Multiline = true;
80 | this.tabTable.Name = "tabTable";
81 | this.tabTable.Padding = new System.Drawing.Point(20, 6);
82 | this.tabTable.SelectedIndex = 0;
83 | this.tabTable.Size = new System.Drawing.Size(1216, 322);
84 | this.tabTable.TabIndex = 0;
85 | //
86 | // tabData
87 | //
88 | this.tabData.Controls.Add(this.grdData);
89 | this.tabData.Location = new System.Drawing.Point(30, 4);
90 | this.tabData.Name = "tabData";
91 | this.tabData.Padding = new System.Windows.Forms.Padding(3);
92 | this.tabData.Size = new System.Drawing.Size(1182, 314);
93 | this.tabData.TabIndex = 0;
94 | this.tabData.Text = "Data";
95 | this.tabData.UseVisualStyleBackColor = true;
96 | //
97 | // grdData
98 | //
99 | this.grdData.AllowUserToAddRows = false;
100 | this.grdData.AllowUserToDeleteRows = false;
101 | this.grdData.AllowUserToResizeRows = false;
102 | this.grdData.BackgroundColor = System.Drawing.SystemColors.Control;
103 | this.grdData.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
104 | this.grdData.Dock = System.Windows.Forms.DockStyle.Fill;
105 | this.grdData.Location = new System.Drawing.Point(3, 3);
106 | this.grdData.Name = "grdData";
107 | this.grdData.ReadOnly = true;
108 | this.grdData.RowHeadersWidth = 20;
109 | this.grdData.RowTemplate.Height = 18;
110 | this.grdData.Size = new System.Drawing.Size(1176, 308);
111 | this.grdData.TabIndex = 28;
112 | this.grdData.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.grdData_DataError);
113 | //
114 | // tabSchema
115 | //
116 | this.tabSchema.Controls.Add(this.grdSchema);
117 | this.tabSchema.Location = new System.Drawing.Point(30, 4);
118 | this.tabSchema.Name = "tabSchema";
119 | this.tabSchema.Padding = new System.Windows.Forms.Padding(3);
120 | this.tabSchema.Size = new System.Drawing.Size(1182, 314);
121 | this.tabSchema.TabIndex = 1;
122 | this.tabSchema.Text = "Schema";
123 | this.tabSchema.UseVisualStyleBackColor = true;
124 | //
125 | // grdSchema
126 | //
127 | this.grdSchema.AllowUserToAddRows = false;
128 | this.grdSchema.AllowUserToDeleteRows = false;
129 | this.grdSchema.AllowUserToResizeRows = false;
130 | this.grdSchema.AutoGenerateColumns = false;
131 | this.grdSchema.BackgroundColor = System.Drawing.SystemColors.Control;
132 | this.grdSchema.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
133 | this.grdSchema.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
134 | this.columnNameDataGridViewTextBoxColumn,
135 | this.dataTypeNameDataGridViewTextBoxColumn,
136 | this.dataTypeDataGridViewTextBoxColumn,
137 | this.columnSizeDataGridViewTextBoxColumn,
138 | this.NumericScale,
139 | this.numericPrecisionDataGridViewTextBoxColumn,
140 | this.allowDBNullDataGridViewCheckBoxColumn,
141 | this.isKeyDataGridViewCheckBoxColumn,
142 | this.isIdentityDataGridViewCheckBoxColumn,
143 | this.isAutoIncrementDataGridViewCheckBoxColumn});
144 | this.grdSchema.DataSource = this.sqlColumnBindingSource;
145 | this.grdSchema.Dock = System.Windows.Forms.DockStyle.Fill;
146 | this.grdSchema.Location = new System.Drawing.Point(3, 3);
147 | this.grdSchema.Margin = new System.Windows.Forms.Padding(2);
148 | this.grdSchema.Name = "grdSchema";
149 | this.grdSchema.ReadOnly = true;
150 | this.grdSchema.RowHeadersVisible = false;
151 | this.grdSchema.RowHeadersWidth = 20;
152 | this.grdSchema.RowTemplate.Height = 18;
153 | this.grdSchema.Size = new System.Drawing.Size(1176, 308);
154 | this.grdSchema.TabIndex = 26;
155 | //
156 | // columnNameDataGridViewTextBoxColumn
157 | //
158 | this.columnNameDataGridViewTextBoxColumn.DataPropertyName = "ColumnName";
159 | this.columnNameDataGridViewTextBoxColumn.HeaderText = "ColumnName";
160 | this.columnNameDataGridViewTextBoxColumn.Name = "columnNameDataGridViewTextBoxColumn";
161 | this.columnNameDataGridViewTextBoxColumn.ReadOnly = true;
162 | //
163 | // dataTypeNameDataGridViewTextBoxColumn
164 | //
165 | this.dataTypeNameDataGridViewTextBoxColumn.DataPropertyName = "DataTypeName";
166 | this.dataTypeNameDataGridViewTextBoxColumn.HeaderText = "DataTypeName";
167 | this.dataTypeNameDataGridViewTextBoxColumn.Name = "dataTypeNameDataGridViewTextBoxColumn";
168 | this.dataTypeNameDataGridViewTextBoxColumn.ReadOnly = true;
169 | //
170 | // dataTypeDataGridViewTextBoxColumn
171 | //
172 | this.dataTypeDataGridViewTextBoxColumn.DataPropertyName = "DataType";
173 | this.dataTypeDataGridViewTextBoxColumn.HeaderText = "DataType";
174 | this.dataTypeDataGridViewTextBoxColumn.Name = "dataTypeDataGridViewTextBoxColumn";
175 | this.dataTypeDataGridViewTextBoxColumn.ReadOnly = true;
176 | //
177 | // columnSizeDataGridViewTextBoxColumn
178 | //
179 | this.columnSizeDataGridViewTextBoxColumn.DataPropertyName = "ColumnSize";
180 | this.columnSizeDataGridViewTextBoxColumn.HeaderText = "ColumnSize";
181 | this.columnSizeDataGridViewTextBoxColumn.Name = "columnSizeDataGridViewTextBoxColumn";
182 | this.columnSizeDataGridViewTextBoxColumn.ReadOnly = true;
183 | //
184 | // NumericScale
185 | //
186 | this.NumericScale.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
187 | this.NumericScale.DataPropertyName = "NumericScale";
188 | this.NumericScale.FillWeight = 8F;
189 | this.NumericScale.HeaderText = "NumericScale";
190 | this.NumericScale.Name = "NumericScale";
191 | this.NumericScale.ReadOnly = true;
192 | //
193 | // numericPrecisionDataGridViewTextBoxColumn
194 | //
195 | this.numericPrecisionDataGridViewTextBoxColumn.DataPropertyName = "NumericPrecision";
196 | this.numericPrecisionDataGridViewTextBoxColumn.HeaderText = "NumericPrecision";
197 | this.numericPrecisionDataGridViewTextBoxColumn.Name = "numericPrecisionDataGridViewTextBoxColumn";
198 | this.numericPrecisionDataGridViewTextBoxColumn.ReadOnly = true;
199 | //
200 | // allowDBNullDataGridViewCheckBoxColumn
201 | //
202 | this.allowDBNullDataGridViewCheckBoxColumn.DataPropertyName = "AllowDBNull";
203 | this.allowDBNullDataGridViewCheckBoxColumn.HeaderText = "AllowDBNull";
204 | this.allowDBNullDataGridViewCheckBoxColumn.Name = "allowDBNullDataGridViewCheckBoxColumn";
205 | this.allowDBNullDataGridViewCheckBoxColumn.ReadOnly = true;
206 | //
207 | // isKeyDataGridViewCheckBoxColumn
208 | //
209 | this.isKeyDataGridViewCheckBoxColumn.DataPropertyName = "IsKey";
210 | this.isKeyDataGridViewCheckBoxColumn.HeaderText = "IsKey";
211 | this.isKeyDataGridViewCheckBoxColumn.Name = "isKeyDataGridViewCheckBoxColumn";
212 | this.isKeyDataGridViewCheckBoxColumn.ReadOnly = true;
213 | //
214 | // isIdentityDataGridViewCheckBoxColumn
215 | //
216 | this.isIdentityDataGridViewCheckBoxColumn.DataPropertyName = "IsIdentity";
217 | this.isIdentityDataGridViewCheckBoxColumn.HeaderText = "IsIdentity";
218 | this.isIdentityDataGridViewCheckBoxColumn.Name = "isIdentityDataGridViewCheckBoxColumn";
219 | this.isIdentityDataGridViewCheckBoxColumn.ReadOnly = true;
220 | //
221 | // isAutoIncrementDataGridViewCheckBoxColumn
222 | //
223 | this.isAutoIncrementDataGridViewCheckBoxColumn.DataPropertyName = "IsAutoIncrement";
224 | this.isAutoIncrementDataGridViewCheckBoxColumn.HeaderText = "IsAutoIncrement";
225 | this.isAutoIncrementDataGridViewCheckBoxColumn.Name = "isAutoIncrementDataGridViewCheckBoxColumn";
226 | this.isAutoIncrementDataGridViewCheckBoxColumn.ReadOnly = true;
227 | //
228 | // sqlColumnBindingSource
229 | //
230 | this.sqlColumnBindingSource.DataSource = typeof(POCOGenerator.Entities.SqlColumn);
231 | //
232 | // tableResult
233 | //
234 | this.tableResult.ColumnCount = 1;
235 | this.tableResult.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
236 | this.tableResult.Controls.Add(this.txtCode, 0, 0);
237 | this.tableResult.Controls.Add(this.tabTable, 0, 1);
238 | this.tableResult.Dock = System.Windows.Forms.DockStyle.Fill;
239 | this.tableResult.Location = new System.Drawing.Point(0, 0);
240 | this.tableResult.Name = "tableResult";
241 | this.tableResult.RowCount = 2;
242 | this.tableResult.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 55F));
243 | this.tableResult.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 45F));
244 | this.tableResult.Size = new System.Drawing.Size(1222, 728);
245 | this.tableResult.TabIndex = 1;
246 | //
247 | // txtCode
248 | //
249 | this.txtCode.BackColor = System.Drawing.Color.White;
250 | this.txtCode.Dock = System.Windows.Forms.DockStyle.Fill;
251 | this.txtCode.Font = new System.Drawing.Font("Courier New", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
252 | this.txtCode.ForeColor = System.Drawing.Color.Blue;
253 | this.txtCode.Location = new System.Drawing.Point(2, 2);
254 | this.txtCode.Margin = new System.Windows.Forms.Padding(2);
255 | this.txtCode.Multiline = true;
256 | this.txtCode.Name = "txtCode";
257 | this.txtCode.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
258 | this.txtCode.Size = new System.Drawing.Size(1218, 396);
259 | this.txtCode.TabIndex = 27;
260 | this.txtCode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtCode_KeyDown);
261 | //
262 | // baseColumnNameDataGridViewTextBoxColumn
263 | //
264 | this.baseColumnNameDataGridViewTextBoxColumn.DataPropertyName = "BaseColumnName";
265 | this.baseColumnNameDataGridViewTextBoxColumn.HeaderText = "BaseColumnName";
266 | this.baseColumnNameDataGridViewTextBoxColumn.Name = "baseColumnNameDataGridViewTextBoxColumn";
267 | this.baseColumnNameDataGridViewTextBoxColumn.ReadOnly = true;
268 | //
269 | // baseTableNameDataGridViewTextBoxColumn
270 | //
271 | this.baseTableNameDataGridViewTextBoxColumn.DataPropertyName = "BaseTableName";
272 | this.baseTableNameDataGridViewTextBoxColumn.HeaderText = "BaseTableName";
273 | this.baseTableNameDataGridViewTextBoxColumn.Name = "baseTableNameDataGridViewTextBoxColumn";
274 | this.baseTableNameDataGridViewTextBoxColumn.ReadOnly = true;
275 | //
276 | // providerSpecificDataTypeDataGridViewTextBoxColumn
277 | //
278 | this.providerSpecificDataTypeDataGridViewTextBoxColumn.DataPropertyName = "ProviderSpecificDataType";
279 | this.providerSpecificDataTypeDataGridViewTextBoxColumn.HeaderText = "ProviderSpecificDataType";
280 | this.providerSpecificDataTypeDataGridViewTextBoxColumn.Name = "providerSpecificDataTypeDataGridViewTextBoxColumn";
281 | this.providerSpecificDataTypeDataGridViewTextBoxColumn.ReadOnly = true;
282 | //
283 | // columnOrdinalDataGridViewTextBoxColumn
284 | //
285 | this.columnOrdinalDataGridViewTextBoxColumn.DataPropertyName = "ColumnOrdinal";
286 | this.columnOrdinalDataGridViewTextBoxColumn.HeaderText = "ColumnOrdinal";
287 | this.columnOrdinalDataGridViewTextBoxColumn.Name = "columnOrdinalDataGridViewTextBoxColumn";
288 | this.columnOrdinalDataGridViewTextBoxColumn.ReadOnly = true;
289 | //
290 | // numericScaleDataGridViewTextBoxColumn
291 | //
292 | this.numericScaleDataGridViewTextBoxColumn.DataPropertyName = "NumericScale";
293 | this.numericScaleDataGridViewTextBoxColumn.HeaderText = "NumericScale";
294 | this.numericScaleDataGridViewTextBoxColumn.Name = "numericScaleDataGridViewTextBoxColumn";
295 | this.numericScaleDataGridViewTextBoxColumn.ReadOnly = true;
296 | //
297 | // providerTypeDataGridViewTextBoxColumn
298 | //
299 | this.providerTypeDataGridViewTextBoxColumn.DataPropertyName = "ProviderType";
300 | this.providerTypeDataGridViewTextBoxColumn.HeaderText = "ProviderType";
301 | this.providerTypeDataGridViewTextBoxColumn.Name = "providerTypeDataGridViewTextBoxColumn";
302 | this.providerTypeDataGridViewTextBoxColumn.ReadOnly = true;
303 | //
304 | // nonVersionedProviderTypeDataGridViewTextBoxColumn
305 | //
306 | this.nonVersionedProviderTypeDataGridViewTextBoxColumn.DataPropertyName = "NonVersionedProviderType";
307 | this.nonVersionedProviderTypeDataGridViewTextBoxColumn.HeaderText = "NonVersionedProviderType";
308 | this.nonVersionedProviderTypeDataGridViewTextBoxColumn.Name = "nonVersionedProviderTypeDataGridViewTextBoxColumn";
309 | this.nonVersionedProviderTypeDataGridViewTextBoxColumn.ReadOnly = true;
310 | //
311 | // isUniqueDataGridViewCheckBoxColumn
312 | //
313 | this.isUniqueDataGridViewCheckBoxColumn.DataPropertyName = "IsUnique";
314 | this.isUniqueDataGridViewCheckBoxColumn.HeaderText = "IsUnique";
315 | this.isUniqueDataGridViewCheckBoxColumn.Name = "isUniqueDataGridViewCheckBoxColumn";
316 | this.isUniqueDataGridViewCheckBoxColumn.ReadOnly = true;
317 | //
318 | // isColumnSetDataGridViewCheckBoxColumn
319 | //
320 | this.isColumnSetDataGridViewCheckBoxColumn.DataPropertyName = "IsColumnSet";
321 | this.isColumnSetDataGridViewCheckBoxColumn.HeaderText = "IsColumnSet";
322 | this.isColumnSetDataGridViewCheckBoxColumn.Name = "isColumnSetDataGridViewCheckBoxColumn";
323 | this.isColumnSetDataGridViewCheckBoxColumn.ReadOnly = true;
324 | //
325 | // isRowVersionDataGridViewCheckBoxColumn
326 | //
327 | this.isRowVersionDataGridViewCheckBoxColumn.DataPropertyName = "IsRowVersion";
328 | this.isRowVersionDataGridViewCheckBoxColumn.HeaderText = "IsRowVersion";
329 | this.isRowVersionDataGridViewCheckBoxColumn.Name = "isRowVersionDataGridViewCheckBoxColumn";
330 | this.isRowVersionDataGridViewCheckBoxColumn.ReadOnly = true;
331 | //
332 | // isLongDataGridViewCheckBoxColumn
333 | //
334 | this.isLongDataGridViewCheckBoxColumn.DataPropertyName = "IsLong";
335 | this.isLongDataGridViewCheckBoxColumn.HeaderText = "IsLong";
336 | this.isLongDataGridViewCheckBoxColumn.Name = "isLongDataGridViewCheckBoxColumn";
337 | this.isLongDataGridViewCheckBoxColumn.ReadOnly = true;
338 | //
339 | // isReadOnlyDataGridViewCheckBoxColumn
340 | //
341 | this.isReadOnlyDataGridViewCheckBoxColumn.DataPropertyName = "IsReadOnly";
342 | this.isReadOnlyDataGridViewCheckBoxColumn.HeaderText = "IsReadOnly";
343 | this.isReadOnlyDataGridViewCheckBoxColumn.Name = "isReadOnlyDataGridViewCheckBoxColumn";
344 | this.isReadOnlyDataGridViewCheckBoxColumn.ReadOnly = true;
345 | //
346 | // ResultContent
347 | //
348 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
349 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
350 | this.Controls.Add(this.tableResult);
351 | this.Name = "ResultContent";
352 | this.Size = new System.Drawing.Size(1222, 728);
353 | this.tabTable.ResumeLayout(false);
354 | this.tabData.ResumeLayout(false);
355 | ((System.ComponentModel.ISupportInitialize)(this.grdData)).EndInit();
356 | this.tabSchema.ResumeLayout(false);
357 | ((System.ComponentModel.ISupportInitialize)(this.grdSchema)).EndInit();
358 | ((System.ComponentModel.ISupportInitialize)(this.sqlColumnBindingSource)).EndInit();
359 | this.tableResult.ResumeLayout(false);
360 | this.tableResult.PerformLayout();
361 | this.ResumeLayout(false);
362 |
363 | }
364 |
365 | #endregion
366 |
367 | private System.Windows.Forms.TabControl tabTable;
368 | private System.Windows.Forms.TabPage tabData;
369 | private System.Windows.Forms.TabPage tabSchema;
370 | private System.Windows.Forms.DataGridView grdData;
371 | internal System.Windows.Forms.DataGridView grdSchema;
372 | private System.Windows.Forms.DataGridViewTextBoxColumn NumericScale;
373 | private System.Windows.Forms.TableLayoutPanel tableResult;
374 | internal System.Windows.Forms.TextBox txtCode;
375 | private System.Windows.Forms.BindingSource sqlColumnBindingSource;
376 | private System.Windows.Forms.DataGridViewTextBoxColumn columnNameDataGridViewTextBoxColumn;
377 | private System.Windows.Forms.DataGridViewTextBoxColumn baseColumnNameDataGridViewTextBoxColumn;
378 | private System.Windows.Forms.DataGridViewTextBoxColumn baseTableNameDataGridViewTextBoxColumn;
379 | private System.Windows.Forms.DataGridViewTextBoxColumn dataTypeDataGridViewTextBoxColumn;
380 | private System.Windows.Forms.DataGridViewTextBoxColumn providerSpecificDataTypeDataGridViewTextBoxColumn;
381 | private System.Windows.Forms.DataGridViewTextBoxColumn dataTypeNameDataGridViewTextBoxColumn;
382 | private System.Windows.Forms.DataGridViewTextBoxColumn columnOrdinalDataGridViewTextBoxColumn;
383 | private System.Windows.Forms.DataGridViewTextBoxColumn columnSizeDataGridViewTextBoxColumn;
384 | private System.Windows.Forms.DataGridViewTextBoxColumn numericPrecisionDataGridViewTextBoxColumn;
385 | private System.Windows.Forms.DataGridViewTextBoxColumn numericScaleDataGridViewTextBoxColumn;
386 | private System.Windows.Forms.DataGridViewTextBoxColumn providerTypeDataGridViewTextBoxColumn;
387 | private System.Windows.Forms.DataGridViewTextBoxColumn nonVersionedProviderTypeDataGridViewTextBoxColumn;
388 | private System.Windows.Forms.DataGridViewCheckBoxColumn isUniqueDataGridViewCheckBoxColumn;
389 | private System.Windows.Forms.DataGridViewCheckBoxColumn isColumnSetDataGridViewCheckBoxColumn;
390 | private System.Windows.Forms.DataGridViewCheckBoxColumn allowDBNullDataGridViewCheckBoxColumn;
391 | private System.Windows.Forms.DataGridViewCheckBoxColumn isKeyDataGridViewCheckBoxColumn;
392 | private System.Windows.Forms.DataGridViewCheckBoxColumn isIdentityDataGridViewCheckBoxColumn;
393 | private System.Windows.Forms.DataGridViewCheckBoxColumn isAutoIncrementDataGridViewCheckBoxColumn;
394 | private System.Windows.Forms.DataGridViewCheckBoxColumn isRowVersionDataGridViewCheckBoxColumn;
395 | private System.Windows.Forms.DataGridViewCheckBoxColumn isLongDataGridViewCheckBoxColumn;
396 | private System.Windows.Forms.DataGridViewCheckBoxColumn isReadOnlyDataGridViewCheckBoxColumn;
397 | }
398 | }
399 |
--------------------------------------------------------------------------------