Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 12, 2025

Summary

Fixes Visual Basic compilation error where dataEntities.Products returns DbSet(Of Product) but code attempted to cast to ObjectQuery(Of Product). Migrates code snippets from legacy location to current standard.

Fixes #2077

Bug Fix

Before (broken):

Imports System.Data.Objects
Dim products As ObjectQuery(Of Product) = dataEntities.Products  ' Type mismatch error
Dim query = From product In products ...

After (fixed):

Imports System.Linq
Dim query = From product In dataEntities.Products ...  ' Type inference handles DbSet correctly

Migration

  • Moved snippets from ~/samples/snippets/ to ./snippets/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control/framework/
  • Updated article references from legacy [!code-...] to modern :::code...::: syntax
  • Replaced numeric snippet IDs (#2) with descriptive identifiers (LoadDataFromDatabase)
  • Created SDK-style project files targeting .NET Framework 4.8
  • Improved C# LINQ query formatting with proper indentation for better readability
  • Removed 31 legacy files after confirming no other articles reference them

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Internal previews

📄 File 🔗 Preview link
dotnet-desktop-guide/wpf/controls/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control.md dotnet-desktop-guide/wpf/controls/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control

Copilot AI and others added 2 commits November 12, 2025 22:58
…atch

Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix value conversion error from DbSet to ObjectQuery Fix VB type mismatch in DataGrid SQL EF walkthrough and migrate snippets Nov 12, 2025
Copilot AI requested a review from adegeo November 12, 2025 23:07
Copilot finished work on behalf of adegeo November 12, 2025 23:07
Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
Copilot AI requested a review from adegeo November 12, 2025 23:58
Copilot finished work on behalf of adegeo November 12, 2025 23:58
@adegeo adegeo marked this pull request as ready for review November 18, 2025 20:14
Copilot AI review requested due to automatic review settings November 18, 2025 20:14
Copilot finished reviewing on behalf of adegeo November 18, 2025 20:15
@adegeo adegeo requested a review from BillWagner November 18, 2025 20:17
@adegeo adegeo enabled auto-merge (squash) November 18, 2025 20:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a Visual Basic compilation error in a WPF DataGrid SQL Entity Framework walkthrough and migrates code snippets to the current standard location. The type mismatch occurred because dataEntities.Products returns ObjectSet(Of Product) (not DbSet), but the code attempted to cast it to ObjectQuery(Of Product).

Key changes:

  • Fixed VB type mismatch by removing unnecessary intermediate variable and using LINQ directly on the entity set
  • Migrated snippets from ~/samples/snippets/ to ./snippets/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control/framework/
  • Updated documentation to use modern :::code::: syntax instead of legacy [!code-...] syntax
  • Replaced numeric snippet IDs with descriptive identifiers
  • Created SDK-style project files targeting .NET Framework 4.8

Reviewed Changes

Copilot reviewed 21 out of 35 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control.md Updated snippet references to new location and modern syntax
MainWindow.xaml.vb Fixed type mismatch by removing ObjectQuery cast and using direct LINQ query
MainWindow.xaml.cs Updated import statements and improved LINQ query indentation
MainWindow.xaml (C# and VB) Added complete XAML files with updated snippet markers
DataGridSQLExample.csproj/vbproj Created SDK-style project files for both languages
App.xaml, App.Config, Application.xaml Added supporting application files
AdventureWorksModel.edmx, Designer files Added Entity Framework model files
Legacy files Removed 31 legacy files from old snippet location
Files not reviewed (4)
  • dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/DataGrid_SQL_EF_Walkthrough/CS/Properties/Resources.Designer.cs: Language not supported
  • dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/DataGrid_SQL_EF_Walkthrough/CS/Properties/Settings.Designer.cs: Language not supported
  • dotnet-desktop-guide/samples/snippets/visualbasic/VS_Snippets_Wpf/DataGrid_SQL_EF_Walkthrough/VB/My Project/Resources.Designer.vb: Language not supported
  • dotnet-desktop-guide/samples/snippets/visualbasic/VS_Snippets_Wpf/DataGrid_SQL_EF_Walkthrough/VB/My Project/Settings.Designer.vb: Language not supported

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.

This LGTM @adegeo

Let's :shipit:

@adegeo adegeo merged commit 52a01b2 into main Nov 19, 2025
13 checks passed
@adegeo adegeo deleted the copilot/fix-dbset-to-objectquery-error branch November 19, 2025 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Value of Type Dbset(Of Product) can't be converted to value Object Query(Of Product)

3 participants