Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8633383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:28:59+00:00 2026-06-12T09:28:59+00:00

I am trying to bind results returned from queries with dynamic where clauses to

  • 0

I am trying to bind results returned from queries with dynamic where clauses to a WPF DataGrid.

Using Database.SqlQuery there seems to be no Load() method and no Local() to return an ObservableCollection.
Thus I am using New ObservableCollection(Of Product)(q1).
Is this the recommended usage, or am I missing something?

Using DbSet.SqlQuery I found no way to get at the data at all.
How is this supposed to be used?

Dim _dbc As New AdventureWorksEntities

''Using DbSet
'Dim q = _dbc.Product
'q.Load()
'Dim r = q.Local
'grd.ItemsSource = r

Const sql = "select * from production.product WHERE name LIKE 'fla%' and ProductNumber LIKE '%0'"
'Using Database.SqlQuery
Dim q1 = _dbc.Database.SqlQuery(Of Product)(sql)
Dim r1 = New ObservableCollection(Of Product)(q1)
grd.ItemsSource = r1

''Using DbSet.SqlQuery
'Dim q2 = _dbc.Product.SqlQuery(sql)
''Dim r2 = ???
''grd.ItemsSource = r2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:29:00+00:00Added an answer on June 12, 2026 at 9:29 am

    You should be able to achieve what you are looking for by doing the following.

    ' Load the products
    _dbc.Products.SqlQuery(sql).ToList()
    
    ' Bind to all loaded products
    grd.ItemsSource = _dbc.Products.Local
    

    Also note that the results of Database.SqlQuery() are never tracked in the context so you will have to use DbSet.SqlQuery() if you want to bind to the results using DbSet.Local.

    For more information on what DbSet.Local actually contains, please refer to its documentation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to loop over a set of results using MySQLi and the bind
I am trying to bind a DataGrid to a generic list in WPF. The
I'm trying to bind a Silverlight DataGrid to the results of a WCF service
I'm trying to loop over a set of results using MySQLi and the bind
I am trying to bind a model coming from the server over json to
How do I bind information from my database to a TextView ? The ListView
I am trying to create a table using CGI.pm. The table would contain results
I am trying to bind to the results of a Linq-To-SQL query, which I
I've been trying to make a dynamic class for my mysqli queries because I'm
I'm trying to bind an ASP.net DropDownList to the results of an entity framework

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.