0

My last question was not clear. Im trying to make a web service in VB.net is their a way that i can return the results that i get from LINQ. ie "return objreturnLINQResults" I have tryed to set my Public Function GetAlarmsByGUIS(ByVal DeptGUID As String, ByVal IdNumber As String) As Linq.DataContext . i just keep getting errors. help please.

Public Function GetAlarmsByGUIS(ByVal DeptGUID As String, ByVal IdNumber As String) As Linq.DataContext
    Dim lqAlarms As New linqAlarmDumpDataContext
    Dim Temp As String = ""
    Dim n As Integer = 0
    Dim GetAlrms = From r In lqAlarms.AlarmDrops _
                   Where r.DeptGUID = DeptGUID And Not r.AlarmsHandled.Contains(IdNumber) _
                   Order By r.TimeDate Descending _
                   Select r


    Return GetAlrms
End Function

1 Answer 1

1

1) You can't create web service's method which returns DataContext object.Return values and input parameters of Web service methods must be serializable through the XmlSerializer class. DataContext is not serializable

2) The simplest way to avoid errors it is return an array of serializable objects. Like this Return GetAlrms.ToArray();

Sign up to request clarification or add additional context in comments.

2 Comments

OK so if i return an array what do i set the Function as ? Ex Public Function GetAlarmsByGUIS(ByVal DeptGUID As String, ByVal IdNumber As String) As Array it just errors out as well. sorry for being the dum questions but im new to web services.
You have to write like this - Public Function GetAlarmsByGUIS(ByVal DeptGUID As String, ByVal IdNumber As String) As AlarmDrop[]. I am not sure about AlarmDrop type, it must be type of r - variable from linq query. Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.