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

Merge to live 2023-08-23 #4459

Merged
merged 9 commits into from
Aug 24, 2023
186 changes: 97 additions & 89 deletions entity-framework/core/extensions/index.md

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions entity-framework/core/get-started/overview/first-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@ uid: core/get-started/overview/first-app

In this tutorial, you create a .NET Core console app that performs data access against a SQLite database using Entity Framework Core.

You can follow the tutorial by using Visual Studio on Windows, or by using the .NET Core CLI on Windows, macOS, or Linux.
You can follow the tutorial by using Visual Studio on Windows, or by using the .NET CLI on Windows, macOS, or Linux.

[View this article's sample on GitHub](https://github.com/dotnet/EntityFramework.Docs/tree/main/samples/core/GetStarted).

## Prerequisites

Install the following software:

### [.NET Core CLI](#tab/netcore-cli)
### [.NET CLI](#tab/netcore-cli)

* [.NET Core SDK](https://www.microsoft.com/net/download/core).
* [.NET SDK](https://dotnet.microsoft.com/en-us/download).

### [Visual Studio](#tab/visual-studio)

* [Visual Studio 2019 version 16.3 or later](https://www.visualstudio.com/downloads/) with this workload:
* **.NET Core cross-platform development** (under **Other Toolsets**)
* [Visual Studio 2022 version 17.4 or later](https://www.visualstudio.com/downloads/) with this workload:
* **.NET desktop development** (under **Desktop && Mobile**)

---

## Create a new project

### [.NET Core CLI](#tab/netcore-cli)
### [.NET CLI](#tab/netcore-cli)

```dotnetcli
dotnet new console -o EFGetStarted
Expand All @@ -41,15 +41,15 @@ cd EFGetStarted
### [Visual Studio](#tab/visual-studio)

* Open Visual Studio
* Click **Create a new project**
* Select **Console App (.NET Core)** with the **C#** tag and click **Next**
* Click **New project**
* Select **Console App** with the **C#** tag and click **Next**
* Enter **EFGetStarted** for the name and click **Create**

---

## Install Entity Framework Core

To install EF Core, you install the package for the EF Core database provider(s) you want to target. This tutorial uses SQLite because it runs on all platforms that .NET Core supports. For a list of available providers, see [Database Providers](xref:core/providers/index).
To install EF Core, you install the package for the EF Core database provider(s) you want to target. This tutorial uses SQLite because it runs on all platforms that .NET supports. For a list of available providers, see [Database Providers](xref:core/providers/index).

### [.NET Core CLI](#tab/netcore-cli)

Expand All @@ -74,7 +74,7 @@ Tip: You can also install packages by right-clicking on the project and selectin

Define a context class and entity classes that make up the model.

### [.NET Core CLI](#tab/netcore-cli)
### [.NET CLI](#tab/netcore-cli)

* In the project directory, create **Model.cs** with the following code

Expand All @@ -96,7 +96,7 @@ Tip: This application intentionally keeps things simple for clarity. [Connection

The following steps use [migrations](xref:core/managing-schemas/migrations/index) to create a database.

### [.NET Core CLI](#tab/netcore-cli)
### [.NET CLI](#tab/netcore-cli)

* Run the following commands:

Expand Down Expand Up @@ -131,7 +131,7 @@ The following steps use [migrations](xref:core/managing-schemas/migrations/index

## Run the app

### [.NET Core CLI](#tab/netcore-cli)
### [.NET CLI](#tab/netcore-cli)

```dotnetcli
dotnet run
Expand Down
136 changes: 62 additions & 74 deletions entity-framework/core/providers/cosmos/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Function Mappings - Azure Cosmos DB Provider - EF Core
description: Function Mappings of the Azure Cosmos DB EF Core Provider
author: bricelam
ms.date: 10/11/2021
ms.date: 7/26/2023
uid: core/providers/cosmos/functions
---
# Function Mappings of the Azure Cosmos DB EF Core Provider
Expand All @@ -11,85 +11,73 @@ This page shows which .NET members are translated into which SQL functions when

## Date and time functions

| .NET | SQL |
|-----------------------|----------------------|
| DateTime.UtcNow | GetCurrentDateTime() |
| DateTimeOffset.UtcNow | GetCurrentDateTime() |
.NET | SQL
--------------------- | ---
DateTime.UtcNow | GetCurrentDateTime()
DateTimeOffset.UtcNow | GetCurrentDateTime()

## Numeric functions

| .NET | SQL |
|-----------------------|-------------------|
| EF.Functions.Random() | RAND() |
| Math.Abs(value) | ABS(@value) |
| Math.Acos(d) | ACOS(@d) |
| Math.Asin(d) | ASIN(@d) |
| Math.Atan(d) | ATAN(@d) |
| Math.Atan2(y, x) | ATN2(@y, @x) |
| Math.Ceiling(d) | CEILING(@d) |
| Math.Cos(d) | COS(@d) |
| Math.Exp(d) | EXP(@d) |
| Math.Floor(d) | FLOOR(@d) |
| Math.Log(a, newBase) | LOG(@a, @newBase) |
| Math.Log(d) | LOG(@d) |
| Math.Log10(d) | LOG10(@d) |
| Math.Pow(x, y) | POWER(@x, @y) |
| Math.Round(d) | ROUND(@d) |
| Math.Sign(value) | SIGN(@value) |
| Math.Sin(a) | SIN(@a) |
| Math.Sqrt(d) | SQRT(@d) |
| Math.Tan(a) | TAN(@a) |
| Math.Truncate(d) | TRUNC(@d) |
| MathF.Abs(x) | ABS(@x) |
| MathF.Acos(x) | ACOS(@x) |
| MathF.Asin(x) | ASIN(@x) |
| MathF.Atan(x) | ATAN(@x) |
| MathF.Atan2(y, x) | ATN2(@y, @x) |
| MathF.Ceiling(x) | CEILING(@x) |
| MathF.Cos(x) | COS(@x) |
| MathF.Exp(x) | EXP(@x) |
| MathF.Floor(x) | FLOOR(@x) |
| MathF.Log(x, y) | LOG(@x, @y) |
| MathF.Log(x) | LOG(@x) |
| MathF.Log10(x) | LOG10(@x) |
| MathF.Pow(x, y) | POWER(@x, @y) |
| MathF.Round(x) | ROUND(@x) |
| MathF.Sign(x) | SIGN(@x) |
| MathF.Sin(x) | SIN(@x) |
| MathF.Sqrt(x) | SQRT(@x) |
| MathF.Tan(x) | TAN(@x) |
| MathF.Truncate(x) | TRUNC(@x) |
.NET | SQL | Added in
-------------------------- | ----------------- | --------
double.DegreesToRadians(x) | RADIANS(@x) | EF Core 8.0
double.RadiansToDegrees(x) | DEGREES(@x) | EF Core 8.0
EF.Functions.Random() | RAND()
Math.Abs(value) | ABS(@value)
Math.Acos(d) | ACOS(@d)
Math.Asin(d) | ASIN(@d)
Math.Atan(d) | ATAN(@d)
Math.Atan2(y, x) | ATN2(@y, @x)
Math.Ceiling(d) | CEILING(@d)
Math.Cos(d) | COS(@d)
Math.Exp(d) | EXP(@d)
Math.Floor(d) | FLOOR(@d)
Math.Log(a, newBase) | LOG(@a, @newBase)
Math.Log(d) | LOG(@d)
Math.Log10(d) | LOG10(@d)
Math.Pow(x, y) | POWER(@x, @y)
Math.Round(d) | ROUND(@d)
Math.Sign(value) | SIGN(@value)
Math.Sin(a) | SIN(@a)
Math.Sqrt(d) | SQRT(@d)
Math.Tan(a) | TAN(@a)
Math.Truncate(d) | TRUNC(@d)

> [!TIP]
> In addition to the methods listed here, corresponding [generic math](/dotnet/standard/generics/math) implementations
> and [MathF](/dotnet/api/system.mathf) methods are also translated. For example, `Math.Sin`, `MathF.Sin`, `double.Sin`,
> and `float.Sin` all map to the `SIN` function in SQL.

## String functions

| .NET | SQL | Added in |
|---------------------------------------------------------------|------------------------------------------------------------|-------------|
| Regex.IsMatch(input, pattern) | RegexMatch(@pattern, @input) | EF Core 7.0 |
| Regex.IsMatch(input, pattern, options) | RegexMatch(@input, @pattern, @options) | EF Core 7.0 |
| string.Concat(str0, str1) | @str0 + @str1 | |
| string.Equals(a, b, StringComparison.Ordinal) | STRINGEQUALS(@a, @b) | |
| string.Equals(a, b, StringComparison.OrdinalIgnoreCase) | STRINGEQUALS(@a, @b, true) | |
| stringValue.Contains(value) | CONTAINS(@stringValue, @value) | |
| stringValue.EndsWith(value) | ENDSWITH(@stringValue, @value) | |
| stringValue.Equals(value, StringComparison.Ordinal) | STRINGEQUALS(@stringValue, @value) | |
| stringValue.Equals(value, StringComparison.OrdinalIgnoreCase) | STRINGEQUALS(@stringValue, @value, true) | |
| stringValue.FirstOrDefault() | LEFT(@stringValue, 1) | |
| stringValue.IndexOf(value) | INDEX_OF(@stringValue, @value) | |
| stringValue.IndexOf(value, startIndex) | INDEX_OF(@stringValue, @value, @startIndex) | |
| stringValue.LastOrDefault() | RIGHT(@stringValue, 1) | |
| stringValue.Length | LENGTH(@stringValue) | |
| stringValue.Replace(oldValue, newValue) | REPLACE(@stringValue, @oldValue, @newValue) | |
| stringValue.StartsWith(value) | STARTSWITH(@stringValue, @value) | |
| stringValue.Substring(startIndex) | SUBSTRING(@stringValue, @startIndex, LENGTH(@stringValue)) | |
| stringValue.Substring(startIndex, length) | SUBSTRING(@stringValue, @startIndex, @length) | |
| stringValue.ToLower() | LOWER(@stringValue) | |
| stringValue.ToUpper() | UPPER(@stringValue) | |
| stringValue.Trim() | TRIM(@stringValue) | |
| stringValue.TrimEnd() | RTRIM(@stringValue) | |
| stringValue.TrimStart() | LTRIM(@stringValue) | |
.NET | SQL | Added in
------------------------------------------------------------- | ---------------------------------------------------------- | --------
Regex.IsMatch(input, pattern) | RegexMatch(@pattern, @input) | EF Core 7.0
Regex.IsMatch(input, pattern, options) | RegexMatch(@input, @pattern, @options) | EF Core 7.0
string.Concat(str0, str1) | @str0 + @str1
string.Equals(a, b, StringComparison.Ordinal) | STRINGEQUALS(@a, @b)
string.Equals(a, b, StringComparison.OrdinalIgnoreCase) | STRINGEQUALS(@a, @b, true)
stringValue.Contains(value) | CONTAINS(@stringValue, @value)
stringValue.EndsWith(value) | ENDSWITH(@stringValue, @value)
stringValue.Equals(value, StringComparison.Ordinal) | STRINGEQUALS(@stringValue, @value)
stringValue.Equals(value, StringComparison.OrdinalIgnoreCase) | STRINGEQUALS(@stringValue, @value, true)
stringValue.FirstOrDefault() | LEFT(@stringValue, 1)
stringValue.IndexOf(value) | INDEX_OF(@stringValue, @value)
stringValue.IndexOf(value, startIndex) | INDEX_OF(@stringValue, @value, @startIndex)
stringValue.LastOrDefault() | RIGHT(@stringValue, 1)
stringValue.Length | LENGTH(@stringValue)
stringValue.Replace(oldValue, newValue) | REPLACE(@stringValue, @oldValue, @newValue)
stringValue.StartsWith(value) | STARTSWITH(@stringValue, @value)
stringValue.Substring(startIndex) | SUBSTRING(@stringValue, @startIndex, LENGTH(@stringValue))
stringValue.Substring(startIndex, length) | SUBSTRING(@stringValue, @startIndex, @length)
stringValue.ToLower() | LOWER(@stringValue)
stringValue.ToUpper() | UPPER(@stringValue)
stringValue.Trim() | TRIM(@stringValue)
stringValue.TrimEnd() | RTRIM(@stringValue)
stringValue.TrimStart() | LTRIM(@stringValue)

## Miscellaneous functions

| .NET | SQL |
|---------------------------|----------------------|
| collection.Contains(item) | @item IN @collection |
.NET | SQL
--------------------------|----
collection.Contains(item) | @item IN @collection
Loading
Loading