You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace deprecated type provider with Entity Framework Core in F# query expressions documentation (#48751)
* Initial plan
* Replace deprecated type provider with modern in-memory query examples
Co-authored-by: BillWagner <[email protected]>
* Final fixes: handle optional Age field properly and add AI usage disclosure
Co-authored-by: BillWagner <[email protected]>
* Remove redundant query-expressions.fsproj and integrate files into parent project
Co-authored-by: BillWagner <[email protected]>
* Fix date and use ::: syntax for code snippets as requested
Co-authored-by: BillWagner <[email protected]>
* Update docs/fsharp/language-reference/query-expressions.md
* Revert db.Student renaming and fix date to 2025 as requested
Co-authored-by: T-Gro <[email protected]>
* Replace in-memory examples with Entity Framework Core as requested
Co-authored-by: T-Gro <[email protected]>
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: BillWagner <[email protected]>
Co-authored-by: Bill Wagner <[email protected]>
Co-authored-by: T-Gro <[email protected]>
Copy file name to clipboardExpand all lines: docs/fsharp/language-reference/query-expressions.md
+71-56Lines changed: 71 additions & 56 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,8 @@
1
1
---
2
2
title: Query Expressions
3
3
description: Learn about query expression support for LINQ in the F# programming language.
4
-
ms.date: 08/15/2020
4
+
ms.date: 09/26/2025
5
+
ai-usage: ai-assisted
5
6
---
6
7
# Query expressions
7
8
@@ -15,27 +16,9 @@ query { expression }
15
16
16
17
## Remarks
17
18
18
-
Query expressions are a type of computation expression similar to sequence expressions. Just as you specify a sequence by providing code in a sequence expression, you specify a set of data by providing code in a query expression. In a sequence expression, the `yield` keyword identifies data to be returned as part of the resulting sequence. In query expressions, the `select` keyword performs the same function. In addition to the `select` keyword, F# also supports a number of query operators that are much like the parts of a SQL SELECT statement. Here is an example of a simple query expression, along with code that connects to the Northwind OData source.
19
+
Query expressions are a type of computation expression similar to sequence expressions. Just as you specify a sequence by providing code in a sequence expression, you specify a set of data by providing code in a query expression. In a sequence expression, the `yield` keyword identifies data to be returned as part of the resulting sequence. In query expressions, the `select` keyword performs the same function. In addition to the `select` keyword, F# also supports a number of query operators that are much like the parts of a SQL SELECT statement. Here is an example of a simple query expression using Entity Framework Core to query a database.
19
20
20
-
```fsharp
21
-
// Use the OData type provider to create types that can be used to access the Northwind database.
22
-
// Add References to FSharp.Data.TypeProviders and System.Data.Services.Client
23
-
open Microsoft.FSharp.Data.TypeProviders
24
-
25
-
type Northwind = ODataService<"http://services.odata.org/Northwind/Northwind.svc">
In the previous code example, the query expression is in curly braces. The meaning of the code in the expression is, return every customer in the Customers table in the database in the query results. Query expressions return a type that implements <xref:System.Linq.IQueryable%601> and <xref:System.Collections.Generic.IEnumerable%601>, and so they can be iterated using the [Seq module](https://fsharp.github.io/fsharp-core-docs/reference/fsharp-collections-seqmodule.html) as the example shows.
41
24
@@ -53,22 +36,9 @@ This table assumes a database in the following form:
53
36
54
37

55
38
56
-
The code in the tables that follow also assumes the following database connection code. Projects should add references to System.Data, System.Data.Linq, and FSharp.Data.TypeProviders assemblies. The code that creates this database is included at the end of this topic.
57
-
58
-
```fsharp
59
-
open System
60
-
open Microsoft.FSharp.Data.TypeProviders
61
-
open System.Data.Linq.SqlClient
62
-
open System.Linq
63
-
open Microsoft.FSharp.Linq
64
-
65
-
type schema = SqlDataConnection< @"Data Source=SERVER\INSTANCE;Initial Catalog=MyDatabase;Integrated Security=SSPI;" >
66
-
67
-
let db = schema.GetDataContext()
39
+
The code in the tables that follow also assumes the following database connection code using Entity Framework Core. Projects should add package references to `Microsoft.EntityFrameworkCore` and `Microsoft.EntityFrameworkCore.InMemory` (or another EF Core provider for production scenarios). This example uses the in-memory database provider for demonstration purposes, but the same query syntax works with any EF Core provider (SQL Server, PostgreSQL, etc.).
0 commit comments