diff --git a/build.ps1 b/build.ps1 index 109741b..3a0270a 100644 --- a/build.ps1 +++ b/build.ps1 @@ -11,8 +11,8 @@ if ([System.IO.Directory]::Exists('linq2db.github.io')) { Remove-Item linq2db.gi Write-Host Done Write-Host Prepare tooling... -&"nuget.exe" install msdn.4.5.2 -ExcludeVersion -OutputDirectory packages -Prerelease -&"nuget.exe" install docfx.console -ExcludeVersion -OutputDirectory packages +&".\nuget.exe" install msdn.4.5.2 -ExcludeVersion -OutputDirectory packages -Prerelease +&".\nuget.exe" install docfx.console -ExcludeVersion -OutputDirectory packages Write-Host Done Write-Host Build DocFX documentation... diff --git a/local.cmd b/local.cmd index e48269b..641950b 100644 --- a/local.cmd +++ b/local.cmd @@ -7,4 +7,4 @@ ECHO Cannot find nuget.exe. Add it to PATH or place it to current folder ECHO nuget.exe could be downloaded from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe GOTO :EOF ) -powershell -Command .\build.ps1 -deploy $false +pwsh.exe -Command .\build.ps1 -deploy $false diff --git a/source/articles/linq2db/Releases/Release notes b/source/articles/linq2db/Releases/Release notes new file mode 100644 index 0000000..e69de29 diff --git a/source/articles/linq2db/geting-started/Getting started/Install LINQ to DB b/source/articles/linq2db/geting-started/Getting started/Install LINQ to DB new file mode 100644 index 0000000..7008587 --- /dev/null +++ b/source/articles/linq2db/geting-started/Getting started/Install LINQ to DB @@ -0,0 +1,15 @@ +# Installing LINQ to DB +# System requirements + .NET Core 3.1 or higher +# Prerequisites +The following prerequisites are needed to complete this walkthrough: + +- Visual Studio +- Northwind Database +# Create a new project +- Open Visual Studio +- Click **File** > **New** > **Project**... +- From the left menu select **Templates** > **Visual C#** > **Windows Classic Desktop** +- Select the **Console App** (.NET Framework) project template +- Ensure you are targeting .NET Framework 4.5.1 or later +- Give the project a name and click **OK** \ No newline at end of file diff --git a/source/articles/linq2db/geting-started/Getting started/Install LINQ to DB.md b/source/articles/linq2db/geting-started/Getting started/Install LINQ to DB.md new file mode 100644 index 0000000..7388d60 --- /dev/null +++ b/source/articles/linq2db/geting-started/Getting started/Install LINQ to DB.md @@ -0,0 +1,16 @@ +# Install LINQ to DB +# System requirements + .NET Core 3.1 or higher +# Prerequisites +The following prerequisites are needed to complete this walkthrough: + +- Visual Studio +- Northwind Database +# Create a new project +- Open Visual Studio +- Click **File** > **New** > **Project**... +- From the left menu select **Templates** > **Visual C#** > **Windows Classic Desktop** +- Select the **Console App** (.NET Framework) project template +- Ensure you are targeting .NET Framework 4.5.1 or later +- Give the project a name and click **OK** + diff --git a/source/articles/linq2db/geting-started/Getting started/LINQ to DB Overview b/source/articles/linq2db/geting-started/Getting started/LINQ to DB Overview new file mode 100644 index 0000000..e69de29 diff --git a/source/articles/linq2db/geting-started/install.md b/source/articles/linq2db/geting-started/install.md new file mode 100644 index 0000000..7c24238 --- /dev/null +++ b/source/articles/linq2db/geting-started/install.md @@ -0,0 +1,11 @@ +--- +title: Installing LINQ To DB +author: sdanyliv +--- + +# Install LINQ To DB from Nuget + +You can develop many different types of applications that target .NET (Core), .NET Framework, or other platforms supported by LINQ To DB. + +* install main `linq2db` package: `nuget install linq2db` +* install ADO.NET provider(s) from nuget (if they available on nuget) or locally for providers with custom installer diff --git a/source/articles/linq2db/geting-started/toc.yml b/source/articles/linq2db/geting-started/toc.yml new file mode 100644 index 0000000..d63f6c5 --- /dev/null +++ b/source/articles/linq2db/geting-started/toc.yml @@ -0,0 +1,2 @@ +- name: Installing LINQ To DB + href: install.md \ No newline at end of file diff --git a/source/articles/linq2db/toc.yml b/source/articles/linq2db/toc.yml new file mode 100644 index 0000000..612e378 --- /dev/null +++ b/source/articles/linq2db/toc.yml @@ -0,0 +1,2 @@ +- name: Wellcome + href: wellcome.md \ No newline at end of file diff --git a/source/articles/linq2db/welcome.md b/source/articles/linq2db/welcome.md new file mode 100644 index 0000000..17216dd --- /dev/null +++ b/source/articles/linq2db/welcome.md @@ -0,0 +1,75 @@ +# LINQ To DB +**LINQ to DB** is the fastest LINQ database access library offering a superficial, light, quick, and type-safe layer between your POCO objects and your database. + +Architecturally it is one step above micro-ORMs like Dapper, Massive, or PetaPoco, in that you work with LINQ expressions, not magic strings while maintaining a thin abstraction layer between your code and the database. Your queries are checked by the C# compiler and allow for easy refactoring. + +However, it is not as heavy as **LINQ to SQL** or **Entity Framework**. There is no change-tracking, so you have to manage that by yourself, but on the positive side, you get more control and faster access to your data. + +In other words, **LINQ to DB** is type-safe SQL. + +# The model +With **LINQ to DB**, data access is performed using a model. A model is made up of entity classes and a context object that represents a session with the database. The context object allows querying and saving data. For more information, see Creating a Model. + +**LINQ to DB** supports the following model development approaches: +- Generate a model from an existing database. +- Hand code a model to match the database. + +**C#** +```csharp +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; + +namespace Intro; + +public class BloggingContext : DbContext +{ + public DbSet Blogs { get; set; } + public DbSet Posts { get; set; } + + protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer( + @"Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True"); + } +} + +public class Blog +{ + public int BlogId { get; set; } + public string Url { get; set; } + public int Rating { get; set; } + public List Posts { get; set; } +} + +public class Post +{ + public int PostId { get; set; } + public string Title { get; set; } + public string Content { get; set; } + + public int BlogId { get; set; } + public Blog Blog { get; set; } +} +``` +# Querying +Instances of your entity classes are retrieved from the database using Language Integrated Query (LINQ). For more information, see Querying Data. +**C#** +```csharp + using (var db = new BloggingContext()) + { + var blogs = db.Blogs + .Where(b => b.Rating > 3) + .OrderBy(b => b.Url) + .ToList(); + }` +``` +# Saving data +Data is created, deleted, and modified in the database using instances of your entity classes. See Saving Data to learn more. +```csharp +using (var db = new BloggingContext()) +{ + var blog = new Blog { Url = "http://sample.com" }; + db.Blogs.Add(blog); + db.SaveChanges(); +} +``` \ No newline at end of file diff --git a/source/articles/toc.yml b/source/articles/toc.yml index 6668242..a51c6ed 100644 --- a/source/articles/toc.yml +++ b/source/articles/toc.yml @@ -1,3 +1,5 @@ +- name: LINQ to DB + href: linq2db/toc.yml - name: Release Notes href: https://github.com/linq2db/linq2db/wiki/Releases-and-Roadmap - name: Get Started diff --git a/source/toc.yml b/source/toc.yml index c6c553c..1f796d9 100644 --- a/source/toc.yml +++ b/source/toc.yml @@ -4,3 +4,5 @@ href: api/ - name: Linq To DB GitHub href: https://github.com/linq2db +- name: Release Notes + href: https://https://github.com/linq2db/linq2db/wiki/Releases-and-Roadmap \ No newline at end of file