I would like to retrieve data form a table and write Values to a hashtable
Code:
public class MyClass
{
static Hashtable myHash;
static MyClass()
{
Configuration cfg = new Configuration();
cfg.AddAssembly("...");
ISessionFactory factory = cfg.BuildSessionFactory();
ISession session = factory.OpenSession();
ITransaction transaction = session.BeginTransaction();
IList results = session.CreateCriteria(typeof(ProductType)).List();
foreach (ProductType myProduct in results)
{
myHash.Add(myProduct.TypeName, myProduct.TypeId);
}
}
}
the List() Method retrieves all data. But it comes to myHash.Add it always throws an exception "Creating a proxy instance failed". The debugger jumps to code which caused to constructor call of MyClass.
Any idea how I can retrieve all rows of a table and write the name and id column (both are strings) of each row to a hashtable or Enum?
Thanks antoschka