Fix VB type mismatch in DataGrid SQL EF walkthrough and migrate snippets#2151
Merged
Fix VB type mismatch in DataGrid SQL EF walkthrough and migrate snippets#2151
Conversation
…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
adegeo
reviewed
Nov 12, 2025
...ay-data-from-a-sql-server-database-in-a-datagrid-control/framework/csharp/MainWindow.xaml.cs
Show resolved
Hide resolved
Co-authored-by: adegeo <67293991+adegeo@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
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
...data-from-a-sql-server-database-in-a-datagrid-control/framework/vb/DataGridSQLExample.vbproj
Show resolved
Hide resolved
adegeo
approved these changes
Nov 18, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes Visual Basic compilation error where
dataEntities.ProductsreturnsDbSet(Of Product)but code attempted to cast toObjectQuery(Of Product). Migrates code snippets from legacy location to current standard.Fixes #2077
Bug Fix
Before (broken):
After (fixed):
Migration
~/samples/snippets/to./snippets/walkthrough-display-data-from-a-sql-server-database-in-a-datagrid-control/framework/[!code-...]to modern:::code...:::syntax#2) with descriptive identifiers (LoadDataFromDatabase)💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Internal previews