Using Adapter template, version 2.0, runtime libs are at 2.0.50727, running on SQL2005. No custom templates, just using out-o-the-box functionality.
I have a service that caches a readonly list of reference tables. There's a good number of them, all with the same fields (ID, Value), so I am using a generic approach to deal with all of them. I use Activator.CreateInstance to create the appropriate EntityFactory, feed this to an EntityCollection, and fill the collection. Works like a charm... in C#.
I had to port this code to VB.Net (2005), and now I get some strange behavior. No exceptions get thrown, but when I examine my EntityCollection (before and after calling adapter.FetchEntityCollection), i see that most of the fields contain the following text (in Watch window):
"The generic type 'SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore1' was used with the wrong number of generic arguments in assembly 'SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.0.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27'.":"SD.LLBLGen.Pro.ORMSupportClasses.CollectionCore
1"
The collection ends up with the correct number of items, but each item contains the default or null values for whatever type is in the column (-1, Nothing, etc.)
Also, the results are the same if I generate the adapter code using the C# or VB templates.
Any help on this would be appreciated. Below is the VB code, and the C# code that works.
Problem VB.Net code:
'get a factory type for a known entity- this is overkill, but
'i want to make sure there's nothing wrong with the factory
'creation part of this...
Dim f As New C_IndustryTypeEntityFactory
Dim factoryClassFQN As String = f.GetType().AssemblyQualifiedName
Dim factoryType As Type = Type.GetType(factoryClassFQN)
If factoryType Is Nothing Then
Throw New ApplicationException("Failed to resolve code table factory type: " + factoryClassFQN)
End If
'instantiate the factory for the EntityCollection we need
Dim factory As IEntityFactory2 = CType(Activator.CreateInstance(factoryType), IEntityFactory2)
Dim coll As EntityCollection = New EntityCollection(factory)
'fill the collection
Using adp As New DataAccessAdapter()
adp.FetchEntityCollection(coll, Nothing)
End Using
Working C# code:
C_IndustryTypeEntityFactory f = new C_IndustryTypeEntityFactory();
string factoryClassFQN = f.GetType().AssemblyQualifiedName;
Type factoryType = Type.GetType(factoryClassFQN);
if (factoryType == null)
{
throw new ApplicationException("Failed to resolve code table factory type: " + factoryClassFQN);
}
IEntityFactory2 factory = (IEntityFactory2)Activator.CreateInstance(factoryType);
EntityCollection coll = new EntityCollection(factory);
using (DataAccessAdapter adp = new DataAccessAdapter())
{
adp.FetchEntityCollection(coll, null);
}