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 4559296
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:46:07+00:00 2026-05-21T17:46:07+00:00

I have a listbox on my xaml form that I bound to a List(Of

  • 0

I have a listbox on my xaml form that I bound to a List(Of MyType) property. I populated this list like so:

Dim fields As List(Of CheckableFields) = New List(Of CheckableFields)

    Using context As ITIPEntities = New ITIPEntities()

        Try

            Dim propertyInfoList As List(Of PropertyInfo) = GetType(PC).GetProperties().ToList()

            For Each pI In propertyInfoList
                If (pI.PropertyType <> GetType(EntityState) _
                 And pI.PropertyType <> GetType(EntityKey) _
                 And pI.PropertyType <> GetType(EntityCollection(Of DiskDrive)) _
                 And pI.PropertyType <> GetType(EntityCollection(Of Memory)) _
                 And pI.PropertyType <> GetType(EntityCollection(Of Monitor)) _
                 And pI.PropertyType <> GetType(EntityCollection(Of Network)) _
                 And pI.PropertyType <> GetType(EntityCollection(Of Processor))) Then
                    fields.Add(New CheckableFields(pI.Name))
                End If
            Next

        Catch ex As Exception

        End Try

    End Using

Now I’m at the point where the user selects the fields they want included in a report and I need to iterate over the required fields. This is my linq query:

For Each checkedField In _requiredFields
                If checkedField.IsChecked Then
                    If checkedField.FieldData IsNot Nothing AndAlso checkedField.FieldData.Trim IsNot String.Empty Then
                        Dim fieldData As String = checkedField.FieldData
                        Dim name As String = checkedField.Name
                        lquery = From comp In lquery Where CType(comp.GetType.GetProperty(name).GetValue(comp, Nothing), String).ToUpper.Contains(fieldData.ToUpper) Select comp
                    End If
                End If
            Next

Which throws the exception that linq doesn’t recognize the GetValue method.

How can I get the property values dynamically?

Edit:

I couldn’t find a way to do this with Linq to Entities, but I did find a way without Linq that works for me:

For Each field In _requiredFields
                If field.IsChecked Then
                    reportGenerator.AllFields.Add(field.Name)
                    If field.FieldData IsNot Nothing Then
                        For i As Integer = pcs.Count - 1 To 0 Step -1
                            Dim compPropertyValue As String = CType(pcs(i).GetType().GetProperty(field.Name).GetValue(pcs(i), Nothing), String).ToUpper()
                            If Not compPropertyValue.Contains(field.FieldData.ToUpper()) Then
                                pcs.RemoveAt(i)
                            End If
                        Next i
                    End If
                End If
            Next
  • 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-05-21T17:46:08+00:00Added an answer on May 21, 2026 at 5:46 pm

    This construct is not supported in LINQ-to-Entities. It is a designed limitation.
    Try using Entity SQL instead as shown in the following example:
    "SELECT VALUE comp From COMPs AS comp WHERE comp." & name & ".ToUpper().Contains(" & fieldData & ".ToUpper()"

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

Sidebar

Related Questions

In my XAML file, I have a ListBox declared like this : <ListBox x:Name=lstDeck
I have a ListBox containing CheckBoxes. Xaml looks like this: <ListBox x:Name=lbContactTypes> <ListBox.ItemTemplate> <HierarchicalDataTemplate>
I have a ListBox on a form that is bound to an ObservableCollection of
I have a ListBox in a file called Downloads.XAML. The items bound to that
So I have this Xaml inside a ListBox Item Template: <ListBox.ItemTemplate> <DataTemplate> <Grid Height=22
We have a form that contains various elements and a datagrid. When the list
I have XAML similar to this: <ListBox ItemsSource={Binding SearchCriteria, Source={StaticResource model}} SelectionChanged=cboSearchCriterionType_SelectionChanged> <ListBox.ItemTemplate> <DataTemplate>
I have a ListBox whose ItemsSource is bound to a list of objects. The
So, I have this ListBox written in XAML: <ListBox Margin=0 x:Name=ListBox_Main Grid.Row=1 VerticalAlignment=Top FontSize=24
I'm new to WPF data binding. I have a ListBox on a form that

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.