This is a migrated thread and some comments may be shown as answers.
TargetInvocation Exception
1 Answer 7 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nils C.
Top achievements
Rank 1
Nils C. asked on 18 Oct 2012, 03:08 PM
Hi,

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
        Get
 
            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
       Next
 
 
       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

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 23 Oct 2012, 07:37 AM
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,
Alexander
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.
Tags
LINQ (LINQ specific questions)
Asked by
Nils C.
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or