Hi,
I'm converting some code from using DataTables to using LLBLGen-erated Entities. I'm working on converting this chunk of code:
(form.Properties is a Hashtable)
DataColumnCollection cols = ds.Tables[0].Columns;
foreach(DataColumn c in cols)
{
if(!(results.IsNull(c.ColumnName)) && c.AutoIncrement != true)
{
form.Properties[c.ColumnName] = results[c.ColumnName];
}
}
This is what I'm trying:
(survey is an LLBLGen-erated entity)
for(int i=0;i<survey.Fields.Count;i++)
{
if (!survey.Fields[i].IsPrimaryKey)
{
form.Properties[survey.Fields[i].Name] = (! survey.Fields[i].IsNull) ? survey.Fields[i].DbValue : null;
}
}
That code runs without error, but a problem occurs in the code that then accesses the data in the form.Properties Hashtable, which worked before my change. Basically, it seems like doing this:
= results[c.ColumnName];
vs doing this:
= survey.Fields[i].DbValue
causes a different type of object to be put in the hash, and the code that then uses that data doesn't like it and throws an error. I'm thinking I need to cast DbValue in some way, so that the type matches the expected type, but am not sure about that whole line of code in general.
Any ideas?
Thx,
Jack