hey this is the error im getting :
--> Cannot widen from target type to primitive type.
this line produces the error :
temp = o.GetType().InvokeMember("", BindingFlags.CreateInstance, null,
null, null);
==============================================
this is what im trying to do : CODE --->
public object[] selectObjects(object o, string where)
{
object[] objects = null;
try
{
//get object type
Type objectType = o.GetType();
//get object properties (atributes)
get/set
PropertyInfo[] properties =
objectType.GetProperties();
//create table sql header + table Name
string query = "SELECT * FROM `"+
getClassName(objectType) +"` ";
if(where != null)
{
query = query + where + ";";
}
else
{
query = query + ";";
}
System.Console.WriteLine(query);
DataSet result =
this._oconn.getDataSetFromQuery(query);
objects = new
object[result.Tables[0].Rows.Count];
int index = 0;
//try to get info
object temp = new object();
foreach(DataRow row in
result.Tables[0].Rows)
{
temp =
o.GetType().InvokeMember("", BindingFlags.CreateInstance,
null, null, null);
foreach(PropertyInfo pi in
properties)
{
//The row names are the
same as the property names
//and i want to load up
the property values into the object
if(pi.Name !=
"TimeStamp")
{
pi.SetValue(temp,row[pi.Name],null);
}
}
objects[index] = temp;
index ++;
}
}
catch(Exception e)
{
System.Console.WriteLine(e.Message
+System.Environment.NewLine +
e.StackTrace);
}
return objects;
}
private string getClassName(Type o)
{
string[] t = o.FullName.Split('.');
return t[t.Length-1].ToString();
}
==============================================
i just cant figure out how to do this properly .. any one have ideas ?
the table name correspond to the object, and to make sure you have the
right object to instantiate i send in a new object to get the right
reflection information ..
Alexandre