MyCodeGenCS: C# Code Generator for MySQL
MyCodeGenCS is a free C# code generating tool for MySQL. This tool reads your MySQL databases, lists tables and generates codes. Tables in your database become usable classes, and you don't even have to modify any generated sources, but just use them easily. And the useage is really simple.
This software used MySQLDriverCS as MySQL driver.
INSTALLATION
REQUIREMENTS
USAGE
Sorry I've not translated the comments in db.cs.
EXAMPLE
if we have this table called `test' in the MySQL database:
------------------------------------------------------------
Field | Type | Key | Extra |
mid |
int(11) | Primary Key | auto_increment |
name | varchar(50) | ||
phone | varchar(50) |
------------------------------------------------------------
it will generate this code:
look at the Gettest(int mid) function, the mid is the primary key of the table.
------------------------Code begins-------------------------
using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using MySQLDriverCS; namespace codegen.Db { public class test { private int m_mid; private string m_name; private string m_phone; public test(){} public virtual int mid { get { return this.m_mid; } set { this.m_mid = value; } } public virtual string name { get { return this.m_name; } set { this.m_name = value; } } public virtual string phone { get { return this.m_phone; } set { this.m_phone = value; } } public virtual bool Gettest(int mid) { try { MySqldb mydb = new MySqldb(); ; MySQLDataReader myreader; myreader = mydb.ExecSqlReader("select * from test where mid='" + mid + "';"); do { this.m_mid = int.Parse(myreader["mid"].ToString()); this.m_name = myreader["name"].ToString(); this.m_phone = myreader["phone"].ToString(); } while (myreader.Read()); return true; } catch (System.Exception) { return false; } finally{ } } } }
-------------------Code Ends ------------------
COPYRIGHT
MyCodeGenCS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with MySQLDriverCS; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
RELEASE VERSION 1.0 NOTES
Features:
- Lists all databases
- Lists all tables
- Generates .sln and .csproj
- Added a method Get[tablename](key)
- Works for different types of MySQL.
© 2005 MyCodeGenCS Project