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.
Re: Silverlight 4 domainservice query does not return results
have you debugged? is there an exception?
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.
Re: Silverlight 4 domainservice query does not return results
I know silvelright 4 is new but can somebody help?
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.
Re: Silverlight 4 domainservice query does not return results
ok
Code:
vb Code:
Public Function ReturnNewOrderNumber() As String
Retry:
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
Try
Dim Check2 = (From e In Me.ObjectContext.OrderMasters Where e.ordnum = NewOrder Select e).First
GoTo Retry
Catch ex As Exception
Return NewOrder
End Try
Catch ex As Exception
Return "Could Not obtain order"
End Try
End Function
vb Code:
Private Sub Order_Loaded(sender As Object, e As System.Windows.RoutedEventArgs) Handles Me.Loaded
ScheduleDatePicker.SelectedDate = Date.Now
OrderDatePicker.SelectedDate = Date.Now
Try
Dim db As New KattDomContext
orderdata = db.ReturnNewOrderNumber()
AddHandler orderdata.Completed, AddressOf orderCompleted
OrderNumberTextBox.IsEnabled = False
Catch ex As Exception
End Try
End Sub
Private Sub OrderRefreshButton_Click(sender As System.Object, e As System.Windows.RoutedEventArgs) Handles OrderRefreshButton.Click
OrderDetailDomainDataSource.Load()
End Sub
Private Sub orderCompleted(ByVal sender As Object, ByVal e As System.EventArgs)
OrderNumberTextBox.Text = orderdata.Value
End Sub
Re: Silverlight 4 domainservice query does not return results
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)
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.
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.
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.