Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/JoshClose/FluentDatabase
A .NET library created in C# to fluently create any type of database
https://github.com/JoshClose/FluentDatabase
Last synced: 2 months ago
JSON representation
A .NET library created in C# to fluently create any type of database
- Host: GitHub
- URL: https://github.com/JoshClose/FluentDatabase
- Owner: JoshClose
- License: ms-pl
- Created: 2009-08-18T14:35:00.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2009-08-20T19:27:20.000Z (over 15 years ago)
- Last Synced: 2024-11-11T00:02:27.452Z (3 months ago)
- Language: C#
- Homepage:
- Size: 133 KB
- Stars: 78
- Watchers: 19
- Forks: 26
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE.txt
Awesome Lists containing this project
README
FluentDatabase is a library to fluently create a number of different database types.
Currently supported databases are:
- Access
- Firebird
- MySQL
- Oracle
- PostgreSQL
- SQLite
- SQLServerExample:
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 ),
)