Using IEnumerable

2

I saw an example in another post about using IEnumerable

var ent = new EntFuncionarios(); 
IEnumerable<Funcionario> funcionario = ent.Funcionarios;
IEnumerable<Funcionario> temp = funcionario.Where(x => x.FuncID == 2).ToList<Funcionario>();

My question is in relation to the line var ent = new EntFuncionarios() , what is it, is it a method of the class Officials?

    
asked by anonymous 20.11.2014 / 19:45

2 answers

6

No. It is the constructor of class EntFuncionarios() . And it is the entity that represents the employees. It has a connection to the Funcionario class, obviously. It is required for use with the Entity Framework .

It is generated through the .edmx file in the solution. At least when using the Model or Database First templates.

IEnumerable

The IEnumerable is being used for another reason. It represents a concrete type that has an ability to pick item by item from a collection. In this case (you can not talk too much without knowing all the details) it allows you to scan all employees contained in EntFuncionarios . This is done in the last line through a query technique called LINQ .

    
20.11.2014 / 19:49
5

This means that the ent variable has a data instance of type EntFuncionarios already defined in the database.

In other words, it looks like a new data line in the EntFuncionarios table, where all values are null , ready to be instantiated.

    
20.11.2014 / 19:48