I’m just learning to work with partial classes in VB.NET and VS2008. Specifically, I’m trying to extend a LINQ to SQL class that was automatically created by SqlMetal.
The automatically generated class looks like this:
Partial Public Class DataContext Inherits System.Data.Linq.DataContext ... <Table(Name:='dbo.Concessions')> _ Partial Public Class Concession ... <Column(Storage:='_Country', DbType:='Char(2)')> _ Public Property Country() As String ... End Property ... End Class
In a separate file, here’s what I’m trying to do:
Partial Public Class DataContext Partial Public Class Concession Public Function Foo() as String Return DoSomeProcessing(Me.Country) End Function End Class End Class
… but I get blue jaggies under ‘Me.Country‘ and the message 'Country' is not a member of 'DataContext.Concession'. Both halves of the partial class are in the same namespace.
So how do I access the properties of the automatically-generated half of the partial class, from my half of the partial class?
Unless VB.NET generates different stuff in its LINQ to SQL files from C# the classes of the DB tables aren’t within the DataContext class, just beside it.
So you have the class MyNamespace.DataContext.Concession when the other half of the partial class is realy MyNamespace.Concession