locked
WCF Query - Retrieve Data RRS feed

  • Question

  • Hi All,

    I have a LS2011 app and I need to be able to execute a WCF Query return the results back to my screen.

    Here's the data structure:

    Public Class AlertStudentInformation
        <Key()>
        Public Property AlertStudentIdent As Integer
        Public Property StudentIdent As Integer
        Public Property StudentName As String
        Public Property BirthDate As Date
        Public Property Dtp As String
    End Class
    

    Here is the Query:

        <Query(IsDefault:=True)> _
        Public Function GetAlertInformation() As IQueryable(Of AlertStudentInformation)
            Dim AlertStudents As New List(Of ShotWcf.AlertStudentInformation)
    
            Return AlertStudents.AsQueryable
    
        End Function
    
        Public Function GetAlertInformationByStudentIdent(StudentIdent As Integer?) As IQueryable(Of AlertStudentInformation)
            Dim AlertStudents As New List(Of ShotWcf.AlertStudentInformation)
    
            ' Dummy up some records.
            AlertStudents.Add(New AlertStudentInformation With {.AlertStudentIdent = 1, .StudentIdent = CInt(StudentIdent), .BirthDate = #1/2/2001#, .Dtp = "Dtp1", .StudentName = "alfred"})
            AlertStudents.Add(New AlertStudentInformation With {.AlertStudentIdent = 2, .StudentIdent = CInt(StudentIdent), .BirthDate = #11/22/2001#, .Dtp = "Dtp2", .StudentName = "Freddy"})
    
            Return AlertStudents.AsQueryable
    
        End Function
    


    So I added the Query to an existing screen.  Now what I want to do is call the query manually so I set the "Auto Execute Query" to uncheck.  I added a button to put my code in to execute the query but I'm not able to call it passing in my parameter, StudentIdent.

    Any help would be appreciated.

    Dave

    Sunday, August 9, 2015 8:52 PM

Answers

  • Hi Dave!

    I was browsing some old code to see if I can help, but there is nothing special - create dataworkspace, call imported method from ria service with ".execute", but I guess you have some different setup..

    Public Function Posalji_SMS(no As String, SMStekst As String) As SMSMessage
                Dim ws = Application.Current.CreateDataWorkspace.LSSettingsData
                Dim resp = ws.SendSMS(no, SMStekst).Execute().First()
                Return resp
    End Function

    this is excerpt from function called from button from one of screens, but its located in common project cause I needed to make it available on server and client.. Hope that helps..

    btw. does intellisense offers "load" method on your query? I'm not sure anymore how it was on VS10 version..

    Kivito


    Nobody expects the Spanish Inquisition! (M.P.F.C.)



    • Edited by Kivito Tuesday, August 11, 2015 5:31 PM load?
    • Marked as answer by Dave Vorgang Thursday, August 27, 2015 1:05 AM
    Tuesday, August 11, 2015 5:15 PM

All replies

  • So, if anyone knows how to call GetAlertInformationByStudentIdent from my screen I would appreciate it.

    Thanks,

    Dave

    Monday, August 10, 2015 9:54 PM
  • Hi Dave Vorgang,

    After adding the WCF Query into screen with "Add Data Item" window, select the property that you added and open the "Properties" window. Please find the "Parameter Binding" to bind the value of parameter. The detailed steps, please refer to following article.
    http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/52/Using-WCF-RIA-Services-In-LightSwitch-To-Simplify-Your-Application-UI.aspx
     
    Best Regards,
    Weiwei

    Tuesday, August 11, 2015 6:41 AM
    Moderator
  • Thanks Weiwei,

    What I need to do is call the query when the user click a button.  Thats why I set the "Auto Execute Query" to false.

    Does anyone know how I would manually call my routine passing in a property?

    Thanks.

    Tuesday, August 11, 2015 2:37 PM
  • Hi Dave!

    I was browsing some old code to see if I can help, but there is nothing special - create dataworkspace, call imported method from ria service with ".execute", but I guess you have some different setup..

    Public Function Posalji_SMS(no As String, SMStekst As String) As SMSMessage
                Dim ws = Application.Current.CreateDataWorkspace.LSSettingsData
                Dim resp = ws.SendSMS(no, SMStekst).Execute().First()
                Return resp
    End Function

    this is excerpt from function called from button from one of screens, but its located in common project cause I needed to make it available on server and client.. Hope that helps..

    btw. does intellisense offers "load" method on your query? I'm not sure anymore how it was on VS10 version..

    Kivito


    Nobody expects the Spanish Inquisition! (M.P.F.C.)



    • Edited by Kivito Tuesday, August 11, 2015 5:31 PM load?
    • Marked as answer by Dave Vorgang Thursday, August 27, 2015 1:05 AM
    Tuesday, August 11, 2015 5:15 PM
  • There is a Load method on the routine and that worked.

    Thanks.

    Thursday, August 27, 2015 1:05 AM