locked
Problem with Queryable Data RRS feed

  • Question

  • Hi all!

    im new to coding queries and I get stucked in some code for querying data and i hope you can help me out.

    here is the code and the exception i got when "qrybeleg.execute.any"  is performed.

    Dim qrytour As Tour = (From tour In DataWorkspace.wasteitData.Touren Where tour.TourId = Me.Tourbelege_erstellenSuche.SelectedItem.TourId).FirstOrDefault Dim qrytourpositionen As IDataServiceQueryable(Of TourPosition) = From tourpositionen In Me.DataWorkspace.wasteitData.TourPositionen Where tourpositionen.Tour.TourId = qrytour.TourId Order By tourpositionen.LfdNr Ascending Select tourpositionen For Each tourposition As TourPosition In qrytourpositionen Dim qrybeleg As IDataServiceQueryable(Of Beleg) qrybeleg = From mybeleg In Me.DataWorkspace.wasteitData.Belege Where mybeleg.Termin = tourposition.Tour.Datum _ And mybeleg.LeistungsPartnerItem.PartnerId = tourposition.LeistungsPartnerItem.PartnerId _ And mybeleg.RechnungsPartnerItem.PartnerId = tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId Select mybeleg If (qrybeleg.Execute.Any) Then

    ... and so on

     

    brings this exception:

    "The expression is not supported.

    Expression: value(LightSwitchApplication.wasteitData).Belege

    .Where(mybeleg => (((mybeleg.Termin == value(LightSwitchApplication.Tourbelege_erstellenSuche_+_Closure$__3+_Closure$__4).$VB$Local_tourposition.Tour.Datum)

    And (mybeleg.LeistungsPartnerItem.PartnerId == value(LightSwitchApplication.Tourbelege_erstellenSuche_+_Closure$__3+_Closure$__4).$VB$Local_tourposition.LeistungsPartnerItem.PartnerId))

    And (mybeleg.RechnungsPartnerItem.PartnerId == value(LightSwitchApplication.Tourbelege_erstellenSuche_+_Closure$__3+_Closure$__4).$VB$Local_tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId)))

    .Select(mybeleg => mybeleg)"

    i dont know why or what is the problem...

    but if i insert this line of code

    For Each tourposition As TourPosition In qrytourpositionen

    line inserted => tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId.ToString()

    Dim qrybeleg As IDataServiceQueryable(Of Beleg)

    the qrybeleg.execute.any performed without an exception!

    i really dont now what to do here

     Please help!

    Thomas


    • Edited by DarkSideNRW Saturday, July 20, 2013 10:24 AM
    Saturday, July 20, 2013 10:19 AM

Answers

  • i found a solution for this by myself.

    Now it works.

    Thank you all for ur great Support....

    bye

    Thomas

    • Marked as answer by DarkSideNRW Friday, August 2, 2013 4:49 AM
    Friday, August 2, 2013 4:49 AM

All replies

  • Noone here who can help me out?
    a small advice or something?

    Greets

    Thomas

    Monday, July 22, 2013 6:44 PM
  • nobody here can help me out?

    I'm really stucked with this.

    What am i doing wrong?

    Thomas

    Friday, July 26, 2013 5:26 AM
  • It looks like you are implicitly composing two queries together in this line:

    For Each tourposition As TourPosition In qrytourpositionen

    I think if you force an execution of the first query before iterating it, you won't have the problem anymore:

    For Each tourposition As TourPosition In qrytourpositionen.Execute()


    Justin Anderson, LightSwitch Development Team

    Friday, July 26, 2013 5:59 AM
    Moderator
  • Hi Justin,

    Thank you VERY MUCH for your advice.
    I tried it but... same exception as before.

     

            Dim qrytour As Tour = (From tour In DataWorkspace.wasteitData.Touren Where tour.TourId = Me.Tourbelege_erstellenSuche.SelectedItem.TourId).FirstOrDefault
            Dim qrytourpositionen = From tourpositionen In Me.DataWorkspace.wasteitData.TourPositionen
                                    Where tourpositionen.Tour.TourId = qrytour.TourId
                                    Order By tourpositionen.LfdNr Ascending
                                    Select tourpositionen
    
            For Each tourposition As TourPosition In qrytourpositionen.Execute
              'Dim rechnungspartnerid As Integer = tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId
    
              Dim qrybeleg = From mybeleg In Me.DataWorkspace.wasteitData.Belege
                             Where mybeleg.Termin = tourposition.Tour.Datum _
                             And mybeleg.LeistungsPartnerItem.PartnerId = tourposition.LeistungsPartnerItem.PartnerId _
                             And mybeleg.RechnungsPartnerItem.PartnerId = tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId
                             Select mybeleg
    
              If (qrybeleg.Execute.Any) Then 'Exception

    Here is a video about it: http://screencast.com/t/Hqu10X1u

     

    If i try this:

              Dim rechnungspartnerid As Integer = tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId
    
              Dim qrybeleg = From mybeleg In Me.DataWorkspace.wasteitData.Belege
                             Where mybeleg.Termin = tourposition.Tour.Datum _
                             And mybeleg.LeistungsPartnerItem.PartnerId = tourposition.LeistungsPartnerItem.PartnerId _
                             And mybeleg.RechnungsPartnerItem.PartnerId = rechnungspartnerid
                             Select mybeleg

    It seems that when do something with

    tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId

    then everythings fine.

    But i cant believe that this is the way to use Linq Queries.

    Please be so kind and help me out of this. If you need any Information... tell me and i will post it here as soon as possible.

    The underlying external Database is SQL Server 2012.

    Relations:

    tourposition

    => 1:n => AuftragPositionItem

    => n:1 => AuftragItem

    => n:1 => RechnungsPartnerItem

    Again... thank you very much!

    Thomas


    • Edited by DarkSideNRW Friday, July 26, 2013 5:12 PM Edit video link
    Friday, July 26, 2013 5:06 PM
  • i cant find any solution for this.

    Please help!

    Thomas

    Wednesday, July 31, 2013 5:47 AM
  • im working on it for days now...
    when i delete  the line:

            Dim qrytour As Tour = (From tour In DataWorkspace.wasteitData.Touren Where tour.TourId = Me.Tourbelege_erstellenSuche.SelectedItem.TourId).FirstOrDefault
            Dim qrytourpositionen As IDataServiceQueryable(Of TourPosition) = From tourpositionen In Me.DataWorkspace.wasteitData.TourPositionen
                                                                              Where tourpositionen.Tour.TourId = qrytour.TourId
                                                                              Order By tourpositionen.LfdNr Ascending
                                                                              Select tourpositionen
            For Each tourposition As TourPosition In qrytourpositionen
    
              Dim qrybeleg As IDataServiceQueryable(Of Beleg)
              qrybeleg = From mybeleg In Me.DataWorkspace.wasteitData.Belege
                         Where mybeleg.Termin = tourposition.Tour.Datum _
                         And mybeleg.LeistungsPartnerItem.PartnerId = tourposition.LeistungsPartnerItem.PartnerId _
                         DELETE=> And mybeleg.RechnungsPartnerItem.PartnerId = tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId
                         Select mybeleg
              If (qrybeleg.Execute.Any) Then
    
              ... and so on
    
    

    the Expression not supported Error did not come up.
    So something is wrong with

    And mybeleg.RechnungsPartnerItem.PartnerId = tourposition.AuftragPositionItem.AuftragItem.RechnungsPartnerItem.PartnerId

    But what? please help!

    Thomas

    Wednesday, July 31, 2013 9:38 PM
  • i found a solution for this by myself.

    Now it works.

    Thank you all for ur great Support....

    bye

    Thomas

    • Marked as answer by DarkSideNRW Friday, August 2, 2013 4:49 AM
    Friday, August 2, 2013 4:49 AM