GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - JoshClose/FluentDatabase: A .NET library created in C# to fluently create any type of database

BranchesTags
Open more actions menu

Latest commit

 

History

18 Commits
18 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE.txt
LICENSE.txt
 
 
README.markdown
README.markdown
 
 

Repository files navigation

FluentDatabase is a library to fluently create a number of different database types.

Currently supported databases are:

  • Access
  • Firebird
  • MySQL
  • Oracle
  • PostgreSQL
  • SQLite
  • SQLServer

Example:


DatabaseFactory.Create( databaseType )
	.WithName( "Business" )
	.UsingSchema( "Test" )
	.HasTable(
	table => table
	         	.WithName( "Companies" )
	         	.HasColumn(
	         	column => column.WithName( "Id" ).OfType( SqlDbType.Int ).IsAutoIncrementing()
	         	          	.HasConstraint( constraint => constraint.OfType( ConstraintType.NotNull ) )
	         	          	.HasConstraint(
	         	          	constraint => constraint.OfType( ConstraintType.PrimaryKey ).WithName( "PK_Companies_Id" ) )
	         	)
	         	.HasColumn(
	         	column => column.WithName( "Name" ).OfType( SqlDbType.NVarChar, 100 )
	         	          	.HasConstraint( constraint => constraint.OfType( ConstraintType.NotNull ) )
	         	)
	)
	.HasTable(
	table => table
	         	.WithName( "Employees" )
	         	.HasColumn(
	         	column => column.WithName( "Id" ).OfType( SqlDbType.Int ).IsAutoIncrementing()
	         	          	.HasConstraint( constraint => constraint.OfType( ConstraintType.NotNull ) )
	         	          	.HasConstraint(
	         	          	constraint => constraint.OfType( ConstraintType.PrimaryKey ).WithName( "PK_Employees_Id" ) )
	         	)
	         	.HasColumn(
	         	column => column.WithName( "CompanyId" ).OfType( SqlDbType.Int )
	         	          	.HasConstraint( constraint => constraint.OfType( ConstraintType.NotNull ) )
	         	          	.HasConstraint(
	         	          	constraint =>
	         	          	constraint.WithName( "FK_Employees_CompanyId" ).OfType( ConstraintType.ForeignKey ).HasReferenceTo( "Companies", "Id" ) )
	         	)
	         	.HasColumn(
	         	column => column.WithName( "Name" ).OfType( SqlDbType.NVarChar, 50 )
	         	          	.HasConstraint( constraint => constraint.OfType( ConstraintType.NotNull ) )
	         	)
	         	.HasColumn(
	         	column => column.WithName( "Bio" ).OfType( SqlDbType.NVarChar, ColumnSize.Max )
	         	)
	).Write( writer );

Creates the script:


USE [Business]

CREATE TABLE [Test].[Companies]
(
	[Id] INT IDENTITY NOT NULL CONSTRAINT [PK_Companies_Id] PRIMARY KEY,
	[Name] NVARCHAR ( 100 ) NOT NULL,
)

CREATE TABLE [Test].[Employees]
(
	[Id] INT IDENTITY NOT NULL CONSTRAINT [PK_Employees_Id] PRIMARY KEY,
	[CompanyId] INT NOT NULL CONSTRAINT [FK_Employees_CompanyId] FOREIGN KEY REFERENCES [Test].[Companies] ( [Id] ),
	[Name] NVARCHAR ( 50 ) NOT NULL,
	[Bio] NVARCHAR ( MAX ),
)

About

A .NET library created in C# to fluently create any type of database

Resources

Readme
License
Activity

Stars

79 stars

Watchers

17 watching

Forks

27 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.