We have third party class which only accepts arrays of object.
Third Party class :
public class Test
{
public class Input
{
public int testVar { get; set; }
public int testVar2 { get; set; }
}
//some methods
public static List<someType> Convert(Input[] data)
{
//execute some steps
}
}
in DB, we have the data column which we are interested and it has thousand of records.
Id data
1 new Test.Input{ testVar=12,testVar=19}
2 new Test.Input{ testVar=16,testVar=12}
3 new Test.Input{ testVar=26,testVar=11}
-
i am trying to create a class and invoke Convert method of Test class by providing array of Input type object .
public class ImplementTest
{
public void CallConvert()
{
// get the data from DB in list
List<object> Input = new List<object>();
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
cmd.CommandText = "dbo.ReadAll_Input";
con.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
Input.Add(dr["data"]);
}
}
}
}
//convert list object to input type object
var inputs = new Test.Input[]
{
//how to pass Input list efficiently
};
var output = Test.Convert(inputs).ToArray();
}
}
can anyone help me on passing Input list object to Create array of object efficiently please?
Thanks!
List<object> Inputand notList<Test.Input> Input?