Giter Site home page Giter Site logo

yuanrui / codegenerator Goto Github PK

View Code? Open in Web Editor NEW
36.0 4.0 22.0 12.89 MB

一个小而美的代码生成器,基于 Mono T4 引擎,支持数据库:SQL Server、MySql、Oracle、SQLite. CodeGenerator is a template base on generator for database, syntax base on Mono T4 engine. Supported databases are SQL Server, MySQL, Oracle, SQLite.

Home Page: https://github.com/yuanrui/CodeGenerator

License: MIT License

C# 99.86% Thrift 0.14%
codegenerator t4 c-sharp entity-framework thrift layui easyui mono-t4 autocode scaffolding

codegenerator's People

Contributors

yuanrui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

codegenerator's Issues

Importing older projects metadata from Excel into YuanRui

Hello this a nice place to keep the meta data of my projects. I used to have an excel spreadsheet with the table names & two Cols for the name and type, I would like to import that into yaunrui - so I can generate the projects from here.

NameCol
TypeCol

How can I template this excel sheet to a simple C# POCO model class with the name and type

TODO List

  1. I18N.
  2. Select part of template file to generate.
  3. Remove dependency dll, integration mono t4
  4. Support MySql.
  5. Add template:LayUI, Vue etc.
  6. Complete documentation.

.net 7 core

Hello any updates for .net 7 core, and also use either bootstrap 5 or admin lte 4

Sql

Sql Server

IF OBJECT_ID (N'all_columns_info', N'V') IS NOT NULL
	DROP VIEW all_columns_info
GO
-- ==============================================================
--      Author: YuanRui
-- Create date: 2015-7-8
-- Description:	查看当前数据库的数据表中每一列的具体信息
-- ==============================================================
CREATE VIEW all_columns_info
AS
WITH colConsCTE(TABLE_NAME, COLUMN_NAME, CONSTRAINT_TYPE) AS (
     SELECT A.TABLE_NAME, A.COLUMN_NAME, B.CONSTRAINT_TYPE FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE A
     LEFT JOIN INFORMATION_SCHEMA.TABLE_CONSTRAINTS B ON A.CONSTRAINT_NAME = B.CONSTRAINT_NAME AND A.TABLE_NAME = B.TABLE_NAME 
)
SELECT a.object_id AS TableID, a.name AS TableName, b.column_id AS ID, b.name as Name, d.value AS Comment , c.name AS DBType, b.max_length AS 'Length',
	CASE WHEN (SELECT COUNT(1) FROM colConsCTE cte WHERE b.name = cte.COLUMN_NAME AND a.name = cte.TABLE_NAME AND cte.CONSTRAINT_TYPE ='PRIMARY KEY') > 0 THEN 1 ELSE 0 END AS IsPrimaryKey,
	CASE WHEN (SELECT COUNT(1) FROM colConsCTE cte WHERE b.name = cte.COLUMN_NAME AND a.name = cte.TABLE_NAME AND cte.CONSTRAINT_TYPE ='FOREIGN KEY') > 0 THEN 1 ELSE 0 END AS IsForeignKey,
	b.IS_NULLABLE as 'IsNullAble'
FROM sys.tables a 
LEFT JOIN sys.columns b on a.object_id = b.object_id
LEFT JOIN sys.types c on b.user_type_id = c.user_type_id
LEFT JOIN sys.extended_properties d on a.object_id = d.major_id and d.minor_id = b.column_id

GO

Oracle

WITH colConsCTE AS (
     SELECT a.*, b.CONSTRAINT_TYPE FROM user_cons_columns a
     LEFT JOIN user_constraints b ON a.constraint_name = b.constraint_name AND a.table_name = b.table_name 
     WHERE a.TABLE_NAME = :TableName
)

SELECT tab.COLUMN_ID AS Id, tab.TABLE_NAME AS TableName, tab.COLUMN_NAME AS ColumnName, col.COMMENTS AS Remark
, tab.DATA_TYPE AS DbType
, tab.DATA_LENGTH AS Length
, tab.DATA_PRECISION AS Precision
, tab.DATA_SCALE AS Scale
, CASE tab.NULLABLE WHEN 'Y' THEN 1 ELSE 0 END AS IsNullable
, CASE WHEN (SELECT COUNT(1) FROM colConsCTE cte WHERE tab.COLUMN_NAME = cte.COLUMN_NAME AND tab.TABLE_NAME = cte.TABLE_NAME AND cte.CONSTRAINT_TYPE ='P') > 0 THEN 1 ELSE 0 END AS IsPrimaryKey
, CASE WHEN (SELECT COUNT(1) FROM colConsCTE cte WHERE tab.COLUMN_NAME = cte.COLUMN_NAME AND tab.TABLE_NAME = cte.TABLE_NAME AND cte.CONSTRAINT_TYPE ='R') > 0 THEN 1 ELSE 0 END AS IsForeignKey
, CASE WHEN (SELECT COUNT(1) FROM colConsCTE cte WHERE tab.COLUMN_NAME = cte.COLUMN_NAME AND tab.TABLE_NAME = cte.TABLE_NAME AND cte.CONSTRAINT_TYPE ='U') > 0 THEN 1 ELSE 0 END AS IsUnique
, CASE WHEN (SELECT COUNT(1) FROM colConsCTE cte WHERE tab.COLUMN_NAME = cte.COLUMN_NAME AND tab.TABLE_NAME = cte.TABLE_NAME AND cte.CONSTRAINT_TYPE ='O') > 0 THEN 1 ELSE 0 END AS IsReadOnly
, 0 AS IsIdentity
FROM USER_TAB_COLUMNS tab
LEFT JOIN USER_COL_COMMENTS col ON tab.table_name = col.table_name AND tab.COLUMN_NAME = col.COLUMN_NAME
WHERE tab.table_name = :TableName

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.