Coder Social home page Coder Social logo

sqlconstantsgenerator's Introduction

SqlConstantsGenerator

Summary

Generates SQL constants as sql-view from C# class or enum.

For example, for this class:

/// <summary> Роли пользователей </summary>
[SqlConstantContainer(ViewName = "const_user_role_type")]
internal enum UserRoleType
{
	/// <summary> Неизвестная роль </summary>
	[SqlConstant(ColumnName = "unknown")] Unknown = 0,

	/// <summary> Клиент </summary>
	[SqlConstant(ColumnName = "client")] Client = 1,

	/// <summary> Супер администратор </summary>
	[SqlConstant(ColumnName = "super_admin")]
	SuperAdmin = 2,

	/// <summary> Технический администратор </summary>
	[SqlConstant(ColumnName = "technical_admin")]
	TechnicalAdmin = 3,

	/// <summary> Маркетолог </summary>
	[SqlConstant(ColumnName = "marketer")] Marketer = 4,

	/// <summary> Тестировщик </summary>
	[SqlConstant(ColumnName = "tester")] Tester = 5,

	/// <summary> Клиентская поддержка </summary>
	[SqlConstant(ColumnName = "client_support")]
	ClientSupport = 6,
}

following file will be generated

--autogenerated by SqlConstantsGenerator v1.0.0.0

create view [const_user_role_type]
with schemabinding
as
select
	0 as unknown,
	1 as client,
	2 as super_admin,
	3 as technical_admin,
	4 as marketer,
	5 as tester,
	6 as client_support
;
go

Usage

  1. Install package:
Install-Package SqlConstantsGenerator
  1. add SqlConstantProvider attribute with optional sql view name to class or enum

  2. build project; new file with sql-view definition will be generated to GeneratedSqlConstants folder in project folder

Notes

  • Output folder for generated files can be customized by setting SqlConstantsGenerator_DestinationFolder property in csproj file.
  • Prefix and postfix sql code can be set via SqlConstantsGenerator_PrefixSql and SqlConstantsGenerator_PostfixSql properties; $viewname$ string in this code will replaced by generated view name.

(see file SqlConstantsGenerator.Tools\SqlConstantsGenerator.props file in sample DbClassesWithCustomSqlFolder project)

sqlconstantsgenerator's People

Contributors

overlord avatar

Watchers

 avatar

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.