tags:

views:

25

answers:

1

Hello,

I have added a table(ViolationsDataSourceConfig) to the dbml file.

The context name is ViolationsDataContext.

I am trying to write a function that should return employee object but it is throwing errors. Below is the code. Is there any easy way for achieving this. I just want the ViolationsDataSourceConfig.

Public Shared Function GetDataSourceDetails(ByVal ApplicationID As Integer) As ViolationsDataSourceConfig
        Dim _db As New ViolationsDataContext
        Dim appSource As New ViolationsDataSourceConfig
        Dim application As Table(Of ViolationsDataSourceConfig) = _db.GetTable(Of ViolationsDataSourceConfig)()
        Try
            appSource = From a In application Where a.ApplicationID = ApplicationID And a.Status = 1 _
                        Select a
                    Catch ex As Exception
                    End Try
        Return appSource
    End Function
+1  A: 

It's a little hard without more information regarding your data structures or the errors you're getting, could you provide the error at least?

Also, you say your LINQ statement should "return employee" but you are typing it as "ViolationsDataSourceConfig", how does that work?

My first thought would be the LINQ statement will return an IEnumerable by default so it probably won't be the correct type.

ppSource = (From a In application Where a.ApplicationID = ApplicationID And a.Status = 1 _
            Select a).FirstOrDefault()

Might be closer to your goal...

MKing