The following method creates a linq-to-sql object at run time based on a class name.
I can also fill the properties of the item via reflection.
But how do I save this object via the linq-to-sql commands if I don't know at runtime which type it is?
public void CreateItem(string className)
{
//create instance of item
string classNamespaceAndName = "TestApp.Models." + className;
Type itemType = Type.GetType(classNamespaceAndName);
item = (object)Activator.CreateInstance(itemType, new Object[] { });
//fill properties through reflection
//save item to the database
db.?????.InsertOnSubmit(item as itemType); //error
db.SubmitChanges();
}