In my VB.NET code, I have something like this:
A collection of clsEmployees
, which is made up of clsEmployee
objects.
I would need a LINQ statement, such that it would return me a DataTable, made up of rows of fields of clsEmployee
, which are supposedly firstname, lastname, employeeID, phone, city etc.
Also, the LINQ statement should return only 开发者_运维百科those rows where phone is not null.
Something like
var aList = empList
.Where((e) => e.phone != null)
.Select((e) => new { firstname : e.firstname, lastname : e.lastname }); // etc
If you really need rows you can use new DataRow(...) in the select.
精彩评论