Hello, I have a doubt, sometime I made this conversion from DataTable to List (C# code):
List<EDog> lstDogs = (from drRow in dsDogs.Tables[0].AsEnumerable()
select
new EDog()
{
intIdDog = drRow.Field<int>("IdDog"),
intIdOwner = drRow.Field<int?>("IdOwner"),
intAge = drRow.Field<int>("Age"),
strName = drRow.Field<string>("Name")
}).ToList();
This worked fine, but now I'm thinking about doing it generic, so that any type of DataSet could be converted to a strongly typed list.
How could I make it generic? maybe a delegate surrounding this part and creating the object?
new EDog()
{
intIdDog = drRow.Field<int>("IdDog"),
intIdOwner = drRow.Field<int?>("IdOwner"),
intAge = drRow.Field<int>("Age"),
strName = drRow.Field<string>("Name")
}
I tried it but get an error:
select (lambda) expected....
Any suggestion?
The reason why I need this is because each DataRow of the result, needs to be converted to an Entity for better manipulation.
Thanks.