TargetInvocation Exception

2 posts, 0 answers
  1. Nils C.
    Nils C. avatar
    41 posts
    Member since:
    Oct 2009

    Posted 18 Oct 2012 Link to this post


    just another Problem:

    We have the following class as extension to our model:

    Partial Public Class Forum_Unterforum
        Private _visible_for_actual_user As Boolean
        ''' <summary>
        ''' Gibt zurück, ob das aktuelle Unterforum vom aktuellen Nutzer gesehen werden darf
        ''' </summary>
        ''' <value>Boolean, ob sichtbar</value>
        Public ReadOnly Property visible_for_actual_user As Boolean
                If _visible_for_actual_user = Nothing Then
                    Dim phq_context1 = phq_context.get_current
                    Dim user_groups = phq_context1.CurrentSystem.current_user.user_groups
                    Dim visible_for_foren_groups = (From it In phq_context1.CurrentSystem.current_customer_db.Forum_Sichtbar_fuer_Benutzergruppe Where it.Forum_Unterforum.Id = Me.Id Select it.Gruppe).ToList
                    _visible_for_actual_user = user_groups.Intersect(visible_for_foren_groups).Any
                End If
                Return _visible_for_actual_user
            End Get
        End Property
    End Class

    And calling here:
    Dim db = _phq_context.CurrentSystem.current_customer_db
           Dim forum_eintrage = db.Forum_Unterforum
           For Each eintrag In forum_eintrage
               Dim eintrag0 = eintrag.visible_for_actual_user
           Dim comboBox_data = (From it In db.Forum_Unterforum Where it.visible_for_actual_user = True _
           Select Text = it.Titel, Value = it.Id Order By Text Ascending).ToList

    In the foreach Loop we get the value "visible_for_actual_user" correctly. When we call the query "combo box_data" we got the following error:

    {"Identifier 'visible_for_actual_user' is not a parameter or variable or field of 'pms_neu.Forum_Unterforum'. If 'visible_for_actual_user' is a property please add the FieldAlias or Storage attribute to it or declare it as a field's alias."}

    Do we miss something?

    Thanks in advance
  2. Alexander
    Alexander avatar
    727 posts

    Posted 23 Oct 2012 Link to this post

    Hi Nils,

    I am afraid that you will not be able to use calculated properties in linq queries. At the moment OpenAccess allows only usage of properties that are mapped to columns in the database. You will have to move the code from the visible_for_actual_user property to the actual linq query being executed.

    Kind regards,
    the Telerik team
    Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
  3. DevCraft banner
Back to Top