private void Debug_Load(object sender, EventArgs e)
{
SQL_DataObject empData = new SQL_DataObject();
Employee objemp = new Employee();
[b]the Error line:[/b] List<Employee> Lst_rcds = empData.Get_Data<Employee>(objemp);
}
public System.Collections.IList Get_Data<T>(object objentity)
{
string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("SPGetStudentByID", con);
cmd.CommandType = CommandType.StoredProcedure;
//SqlParameter param = new SqlParameter("@ID", ID);
//cmd.Parameters.Add(param);
List<T> lst_entity = new List<T>();
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
//lst_entity.Add(Set_EntityFields(objentity));
}
return lst_entity.ToList();
}
throw new NotImplementedException();
}
private object Set_EntityFields<T>(T objentity)
{
setInstanceProperty<object>(objentity, "ID", 123);
return null;
}
static void setInstanceProperty<T>(object instance, string propertyName, T value)
{
Type type = instance.GetType();
PropertyInfo propertyInfo = type.GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public, null, typeof(T), new Type[0], null);
propertyInfo.SetValue(instance, value, null);
return;
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE