hey this is the error im getting :
--> Cannot widen from target type to primitive type.
this line produces the error :
temp = o.GetType().Inv okeMember("", BindingFlags.Cr eateInstance, null,
null, null);
=============== =============== =============== =
this is what im trying to do : CODE --->
public object[] selectObjects(o bject o, string where)
{
object[] objects = null;
try
{
//get object type
Type objectType = o.GetType();
//get object properties (atributes)
get/set
PropertyInfo[] properties =
objectType.GetP roperties();
//create table sql header + table Name
string query = "SELECT * FROM `"+
getClassName(ob jectType) +"` ";
if(where != null)
{
query = query + where + ";";
}
else
{
query = query + ";";
}
System.Console. WriteLine(query );
DataSet result =
this._oconn.get DataSetFromQuer y(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().Inv okeMember("", BindingFlags.Cr eateInstance,
null, null, null);
foreach(Propert yInfo 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(tem p,row[pi.Name],null);
}
}
objects[index] = temp;
index ++;
}
}
catch(Exception e)
{
System.Console. WriteLine(e.Mes sage
+System.Environ ment.NewLine +
e.StackTrace);
}
return objects;
}
private string getClassName(Ty pe o)
{
string[] t = o.FullName.Spli t('.');
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
--> Cannot widen from target type to primitive type.
this line produces the error :
temp = o.GetType().Inv okeMember("", BindingFlags.Cr eateInstance, null,
null, null);
=============== =============== =============== =
this is what im trying to do : CODE --->
public object[] selectObjects(o bject o, string where)
{
object[] objects = null;
try
{
//get object type
Type objectType = o.GetType();
//get object properties (atributes)
get/set
PropertyInfo[] properties =
objectType.GetP roperties();
//create table sql header + table Name
string query = "SELECT * FROM `"+
getClassName(ob jectType) +"` ";
if(where != null)
{
query = query + where + ";";
}
else
{
query = query + ";";
}
System.Console. WriteLine(query );
DataSet result =
this._oconn.get DataSetFromQuer y(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().Inv okeMember("", BindingFlags.Cr eateInstance,
null, null, null);
foreach(Propert yInfo 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(tem p,row[pi.Name],null);
}
}
objects[index] = temp;
index ++;
}
}
catch(Exception e)
{
System.Console. WriteLine(e.Mes sage
+System.Environ ment.NewLine +
e.StackTrace);
}
return objects;
}
private string getClassName(Ty pe o)
{
string[] t = o.FullName.Spli t('.');
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