Question

I'm attempting to read from a SQL-Server database using LINQ like so:-

Public Module MyMod
    Public db As MyDatabaseDataContext
End Module

Partial Public Class MyDatabaseDataContext
    Public ReadOnly Property MyProperty As MyTableRow
        Get
            Static my_object As MyTableRow
            If my_object Is Nothing Then
                my_object = (From a In db.GetTable(Of MyTableRow)()).First
            End If
            return my_object
        End Get
    End Property
End Class

I haven't so far advanced sufficiently in the project to try to run this, but a short while ago I added a stored procedure (by drag 'n' drop) into the MyDatabaseDataContext and have now started to get a compilation error...

'GetTable' is not a member of 'MyProject.MyDatabaseDataContext'

(I have been following this tutorial here for my introduction to LINQ.)

Does anyone know what the matter is?

Était-ce utile?

La solution

Dropping the data context class from the project and recreated it cleared the problem. Attempting to rename the data context class from the default DataClasses1DataContext to MyDatabaseDataContext re-introduced it.

I conclude that the name of the class has to be changed somewhere that is not visible to the naked eye. Rather than fight the tool, I have decided to leave the default name unchanged.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top