X
X
xXNullXx2018-09-17 19:28:00
C++ / C#
xXNullXx, 2018-09-17 19:28:00

How to unload from a table with several fields into a list and then extract this data from the list?

Good day. I apologize if the question was asked incorrectly.
It was necessary to extract certain fields from the table to the sheet, after this was done, it was necessary to display the data from the list (for example, to the console, which was done).

using (var bd = new WS2016Entities())
{
         var dateUser = bd.User.AsEnumerable().Select(date => new User()
         {
               Email = date.Email,
               Password = date.Password,
               RoleId = date.RoleId
          }).ToList();
}

but instead of displaying data, this is displayed:
5b9fd59604856092939147.png
Tell me what the problem is and, if possible, throw off the material on this topic.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LiptonOlolo, 2018-09-17
@xXNullXx

The necessary data can be taken very simply - an anonymous object that contains all the necessary fields:
For example, get all EMail:

using (var db = new WS2016Entities())
{
   var emails = db.User.Select(date => new { Email = date.Email }).ToList();
   
   emails.ForEach(x => Console.WriteLine(x.Email));
}

Specifically for your User model: override(!!) the ToString() method in it, which will return the desired string representation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question