Silverlight 4 domainservice query does not return results-VBForums
Results 1 to 11 of 11

Thread: Silverlight 4 domainservice query does not return results

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Location
    Memphis
    Posts
    20

    Silverlight 4 domainservice query does not return results

    Code:
    Try
            Dim check = (From d In Me.ObjectContext.OrderMasters
                         Group d By d.ordnum Into g = Group
                         Order By ordnum Descending
                         Select ordnum).First
            Dim NewOrder As String = check & Date.Now.Millisecond.ToString
            Return NewOrder
        Catch ex As Exception
            Return "Could Not obtain order"
        End Try
    this doesn't return anything like its not even running anybody have an idea why I can't get the value from the silverlight client.

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,586

    Re: Silverlight 4 domainservice query does not return results

    have you debugged? is there an exception?
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Location
    Memphis
    Posts
    20

    Re: Silverlight 4 domainservice query does not return results

    for some reason I am using the Silvelight business application template. I have debugged it but for some reason it does not ever hit this line of code. Even thouhg it is exposed through the domain service and I can execute it from the client but it always return null even though it should return something regardless of the exception.

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Location
    Memphis
    Posts
    20

    Re: Silverlight 4 domainservice query does not return results

    I know silvelright 4 is new but can somebody help?

  5. #5
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Silverlight 4 domainservice query does not return results

    Can you post a little more than the Try Catch block from your DomainService. Would also like to see how you're calling it from the client side.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Location
    Memphis
    Posts
    20

    Re: Silverlight 4 domainservice query does not return results

    ok
    Code:
    vb Code:
    1. Public Function ReturnNewOrderNumber() As String
    2. Retry:
    3.         Try
    4.             Dim check = (From d In Me.ObjectContext.OrderMasters
    5.                          Group d By d.ordnum Into g = Group
    6.                          Order By ordnum Descending
    7.                          Select ordnum).First
    8.             Dim NewOrder As String = check & Date.Now.Millisecond.ToString
    9.             Try
    10.                 Dim Check2 = (From e In Me.ObjectContext.OrderMasters Where e.ordnum = NewOrder Select e).First
    11.                 GoTo Retry
    12.             Catch ex As Exception
    13.                 Return NewOrder
    14.             End Try
    15.         Catch ex As Exception
    16.             Return "Could Not obtain order"
    17.         End Try
    18.     End Function
    vb Code:
    1. Private Sub Order_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
    2.         ScheduleDatePicker.SelectedDate = Date.Now
    3.         OrderDatePicker.SelectedDate = Date.Now
    4.         Try
    5.             Dim db As New KattDomContext
    6.             orderdata = db.ReturnNewOrderNumber()
    7.             AddHandler orderdata.Completed, AddressOf orderCompleted
    8.             OrderNumberTextBox.IsEnabled = False
    9.         Catch ex As Exception
    10.  
    11.         End Try
    12.     End Sub
    13.  
    14.     Private Sub OrderRefreshButton_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles OrderRefreshButton.Click
    15.         OrderDetailDomainDataSource.Load()
    16.     End Sub
    17.  
    18.     Private Sub orderCompleted(ByVal sender As Object, ByVal e As System.EventArgs)
    19.         OrderNumberTextBox.Text = orderdata.Value
    20.     End Sub

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Location
    Memphis
    Posts
    20

    Re: Silverlight 4 domainservice query does not return results

    Thanks matt

  8. #8
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Silverlight 4 domainservice query does not return results

    I'm going to pretend I didn't see the Retry: GoTo Retry in the code.

    Here's the MSDN article on Domain Services: http://msdn.microsoft.com/en-us/libr...(v=vs.91).aspx

    Try adding the <Invoke()> attribute to your ReturnNewOrderNumber method. If you don't specify this then the return type won't be IEnumerable<T>, IQueryable<T>, or Entity which the query can return. (The Domain Service will assume the <Query()> attribute unless your method name starts with Update, Change, Modify, Insert, Add, Create, Delete or Remove)

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Location
    Memphis
    Posts
    20

    Re: Silverlight 4 domainservice query does not return results

    Wow that worked. Actually I don't know of another way to retry a statement if the order exists. This is actually my first time doing it and I know it's bad code practice but what harm does it do when I know it won't ever just lock up like most go to statements. but if you have a better way please share I am not an expert.

  10. #10
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Silverlight 4 domainservice query does not return results

    I would use a loop so that you can keep looping until a certain condition is met (You have a unique Order Number in your case).

    A quick Google search brought up this as the first result: http://www.startvbdotnet.com/language/loops.aspx Take a look at the While and Do loops.

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jun 2010
    Location
    Memphis
    Posts
    20

    Re: Silverlight 4 domainservice query does not return results

    OMG can I add you as a friend I promise not bumbarded you with questions I am usually a Google look it up guy but I really appreciate your help and I got that nasty GOTO statement removed from my code.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.