Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Documentation update. #41

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
2 changes: 1 addition & 1 deletion local.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Empty file.
Original file line number Diff line number Diff line change
@@ -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**
Original file line number Diff line number Diff line change
@@ -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**

11 changes: 11 additions & 0 deletions source/articles/linq2db/geting-started/install.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions source/articles/linq2db/geting-started/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Installing LINQ To DB
href: install.md
2 changes: 2 additions & 0 deletions source/articles/linq2db/toc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- name: Wellcome
href: wellcome.md
75 changes: 75 additions & 0 deletions source/articles/linq2db/welcome.md
Original file line number Diff line number Diff line change
@@ -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<Blog> Blogs { get; set; }
public DbSet<Post> 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<Post> 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();
}
```
2 changes: 2 additions & 0 deletions source/articles/toc.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions source/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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