Popular DataGridView with Entity Framwork

0
  • I have in SQL Server a database called STORE;
  • In this database I have a table named Functional, it contains 5 columns being respectively: Name, CPF, DataAdmission, DataDemission,
  • In my C # application I have already made the connection to the database through the ADO.NET Model Entity Framwork and the model is called StoreEntities.
  • Now I want the popular datagridview1 with only 3 columns of the Official table, which would respectively; UserID, Name, CPF.
  • What is the best way to make the village?

        
    asked by anonymous 09.06.2017 / 03:58

    1 answer

    0

    Finally, I researched a little more and I think I got the solution. What solves my problem is the so-called anonymous object, where we need to select more than one item from u

    var db = new LojaEntities();
    var consulta = from p in db.Funcionarios select new {p.Nome, p.CPF, p.Endereco};
    datagridview1.DataSource = consulta.ToList();
    
        
    09.06.2017 / 07:13