From 8d1695bd69731a3bf59c929028e4c32b7f2fec70 Mon Sep 17 00:00:00 2001 From: Mariana Hladka Date: Thu, 9 Feb 2023 14:53:13 +0200 Subject: [PATCH 1/4] Added initial documentation changes. --- .../linq2db/geting-started/install.md | 11 +++++++ .../articles/linq2db/geting-started/toc.yml | 2 ++ source/articles/linq2db/toc.yml | 2 ++ source/articles/linq2db/wellcome.md | 31 +++++++++++++++++++ source/articles/toc.yml | 2 ++ 5 files changed, 48 insertions(+) create mode 100644 source/articles/linq2db/geting-started/install.md create mode 100644 source/articles/linq2db/geting-started/toc.yml create mode 100644 source/articles/linq2db/toc.yml create mode 100644 source/articles/linq2db/wellcome.md diff --git a/source/articles/linq2db/geting-started/install.md b/source/articles/linq2db/geting-started/install.md new file mode 100644 index 0000000..60d11bd --- /dev/null +++ b/source/articles/linq2db/geting-started/install.md @@ -0,0 +1,11 @@ +--- +title: Installing LINQ To DB +author: sdanyliv +--- + +# Installing 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/wellcome.md b/source/articles/linq2db/wellcome.md new file mode 100644 index 0000000..fc48455 --- /dev/null +++ b/source/articles/linq2db/wellcome.md @@ -0,0 +1,31 @@ +## Welcome +### 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. +- Generate objects from the database and query them. +- Insert the objects instead of copying them. + +### 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. \ 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 From 764473a04d27d9bad74b39ed0f76d434f15cd9ab Mon Sep 17 00:00:00 2001 From: Mariana Hladka Date: Thu, 9 Feb 2023 16:44:24 +0200 Subject: [PATCH 2/4] Added new sections. --- build.ps1 | 4 ++-- local.cmd | 2 +- source/articles/linq2db/{wellcome.md => welcome.md} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename source/articles/linq2db/{wellcome.md => welcome.md} (100%) 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/wellcome.md b/source/articles/linq2db/welcome.md similarity index 100% rename from source/articles/linq2db/wellcome.md rename to source/articles/linq2db/welcome.md From 5b2298992f0d963f434a82f3218d2a7189f0436b Mon Sep 17 00:00:00 2001 From: Mariana Hladka Date: Mon, 13 Feb 2023 16:02:26 +0200 Subject: [PATCH 3/4] Updated --- .../articles/linq2db/Releases/Release notes | 0 .../Getting started/Install LINQ to DB | 15 +++++ .../Getting started/Install LINQ to DB.md | 15 +++++ .../Getting started/LINQ to DB Overview | 0 source/articles/linq2db/welcome.md | 64 ++++++++++++++++--- source/toc.yml | 2 + 6 files changed, 86 insertions(+), 10 deletions(-) create mode 100644 source/articles/linq2db/Releases/Release notes create mode 100644 source/articles/linq2db/geting-started/Getting started/Install LINQ to DB create mode 100644 source/articles/linq2db/geting-started/Getting started/Install LINQ to DB.md create mode 100644 source/articles/linq2db/geting-started/Getting started/LINQ to DB Overview 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..7008587 --- /dev/null +++ b/source/articles/linq2db/geting-started/Getting started/Install LINQ to DB.md @@ -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/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/welcome.md b/source/articles/linq2db/welcome.md index fc48455..17216dd 100644 --- a/source/articles/linq2db/welcome.md +++ b/source/articles/linq2db/welcome.md @@ -1,21 +1,57 @@ -## Welcome -### LINQ To DB +# 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. +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. +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 + +# 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. -- Generate objects from the database and query them. -- Insert the objects instead of copying them. +- 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; } -### Querying + 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 @@ -27,5 +63,13 @@ Instances of your entity classes are retrieved from the database using Language .ToList(); }` ``` -### Saving data -Data is created, deleted, and modified in the database using instances of your entity classes. See Saving Data to learn more. \ No newline at end of file +# 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/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 From 7ec3e97b2a11b1370c8e0a930545100d21af70d0 Mon Sep 17 00:00:00 2001 From: Mariana Hladka Date: Mon, 20 Feb 2023 10:55:03 +0200 Subject: [PATCH 4/4] Added new information --- .../geting-started/Getting started/Install LINQ to DB.md | 5 +++-- source/articles/linq2db/geting-started/install.md | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) 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 index 7008587..7388d60 100644 --- 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 @@ -1,4 +1,4 @@ -# Installing LINQ to DB +# Install LINQ to DB # System requirements .NET Core 3.1 or higher # Prerequisites @@ -12,4 +12,5 @@ The following prerequisites are needed to complete this walkthrough: - 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 +- Give the project a name and click **OK** + diff --git a/source/articles/linq2db/geting-started/install.md b/source/articles/linq2db/geting-started/install.md index 60d11bd..7c24238 100644 --- a/source/articles/linq2db/geting-started/install.md +++ b/source/articles/linq2db/geting-started/install.md @@ -3,7 +3,7 @@ title: Installing LINQ To DB author: sdanyliv --- -# Installing LINQ To DB from Nuget +# 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.