[ACCEPTED]-From datatable to Entity-datatable
Accepted answer
I'm not sure this is exactly what you're 7 looking for but it should work; there is 6 a .AsEnumerable() extension method which you can then use 5 to project the row into a new entity.
var products = productTable.AsEnumerable().Select(row => new Product
{
ProductID = row.Field<int>("ProductID"),
Name = row.Field<string>("Name"),
CreatedDate = row.Field<DateTime>("CreatedDate")
});
As 4 far as I know the .Field<T>()
method doesn't do any 3 type conversion so if the column hasn't 2 had the type set you will need to do the 1 conversion yourself.
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.