Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 25, 2025

Fix Type Provider Example in Query Expressions Documentation

The type provider example in F# query expressions documentation is using deprecated FSharp.Data.TypeProviders which is not compatible with modern .NET versions (net5.0+).

Plan

  • Analyze the current issue and identify the problem
  • Understand the repository structure for F# snippets
  • Fix the existing F# project file to use correct SDK
  • Create a new query-expressions directory with proper project structure
  • Update the type provider example to use modern alternatives
  • Replace inline code with references to external snippet files
  • Test the updated code compiles with .NET 9
  • Update documentation to match modern F# practices
  • Final testing and validation
  • Address build errors and project structure feedback
  • Fix date and snippet syntax per code review feedback

Resolution Summary

Issue Fixed: Successfully replaced deprecated FSharp.Data.TypeProviders with modern in-memory data approach

Latest Changes (Code Review Fixes):

Documentation Format Updates:

  • Fixed date to 09/26/2024 (corrected from previous date)
  • Updated snippet syntax from [!code-fsharp[Main](...)] to :::code language="fsharp" source="..."::: format as requested by @BillWagner
  • All snippet references now use the proper ::: syntax for code blocks
  • ✅ Project continues to build successfully

Key Changes Made:

  1. Project Structure:

    • Fixed fssamples.fsproj to use correct SDK (Microsoft.NET.Sdk)
    • Removed redundant /samples/snippets/fsharp/query-expressions/query-expressions.fsproj
    • Integrated query-expressions files into parent project targeting .NET 9.0
    • Added FSharp.Data package reference to parent project
  2. Code Modernization:

    • Replaced deprecated type provider with modern record types (Student, Course, CourseSelection)
    • Used AsQueryable() extension for LINQ compatibility
    • Created reusable snippet files: snippet1.fs, snippet2.fs
    • Proper handling of optional Age field with null safety
  3. Documentation Updates:

    • Updated query-expressions.md to use :::code language="fsharp" source="..."::: syntax for external snippets
    • Fixed document date to 09/26/2024
    • Replaced all db.StudentstudentsQueryable, db.CoursecoursesQueryable, etc.
    • Removed deprecated assembly references and old F# Interactive output
    • Fixed query operators to use sortByNullable for optional fields
    • Added proper where clauses for null safety (student.Age.IsSome)
    • Added AI usage disclosure and updated date
  4. Testing & Validation:

    • ✅ Parent project builds successfully with all snippet files
    • ✅ Query expressions work correctly with modern F#
    • ✅ Examples handle optional data types properly
    • ✅ Basic operations (select, count, contains, where, join) all functional
    • ✅ Documentation references remain correct with new syntax

Impact:

  • Developers can now use the query expressions documentation with modern .NET
  • Examples compile and run on .NET 5.0+ including .NET 9.0
  • No more dependency on deprecated type providers
  • Modern F# best practices demonstrated
  • Cleaner project structure following repository conventions
  • Documentation follows current Microsoft Docs formatting standards
Original prompt

This section details on the original issue you should resolve

<issue_title>Type provider example does not seem to work</issue_title>
<issue_description>
Type provider example does not seem to work. It seems to be not compatible with target net5.0.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Comments on the Issue (you are @copilot in this section)

@BillWagner To fix this, let's start by moving the snippets into an F# project and then update the code to ensure it compiles against .NET 9
Fixes #22206

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/fsharp/language-reference/query-expressions.md Query expressions

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Sep 25, 2025
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
…losure

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Type provider example does not seem to work Fix deprecated type provider example in F# query expressions documentation Sep 25, 2025
@Copilot Copilot AI requested a review from BillWagner September 25, 2025 15:13
Copilot finished work on behalf of BillWagner September 25, 2025 15:13
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot You need to fix the build errors.

…rent project

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Sep 26, 2025

@copilot You need to fix the build errors.

Fixed the build errors by removing the redundant query-expressions.fsproj and integrating all files into the parent fssamples.fsproj. The project now builds successfully without any errors. Commit: 9627b65

@Copilot Copilot AI requested a review from BillWagner September 26, 2025 15:14
Copilot finished work on behalf of BillWagner September 26, 2025 15:14
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few things to address here @copilot

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@Copilot Copilot AI requested a review from BillWagner September 26, 2025 18:35
Copilot finished work on behalf of BillWagner September 26, 2025 18:35
@BillWagner BillWagner requested a review from T-Gro September 26, 2025 18:48
@BillWagner
Copy link
Member

Tagging @T-Gro for review, even in draft status.

Is the new sample idiomatic F#? It looks more like C# translated to F#, but in this area, they can be quite similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dotnet-fsharp/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type provider example does not seem to work
2 participants