Retrieve an object in Entity framework (.NET) [closed]

1

I need to recover a single object from the database because I want to load some special options on that record but the most I get is to generate a list.

Would you have any chance of getting that record?

    
asked by andres ribeiro 03.03.2016 в 14:24
source

1 answer

2

You can use the DbSet<TEntity>.Find(params Object[] keyValues)

As a parameter you pass the Id (mapped to the primary key) of the object you want to obtain and it will return only this and not a list.

Example:

Persona p = Db.Personas.Find(23);

Or if the primary key is composed

Categoria q = Db.Categorias.Find(1, 4);
    
answered by 03.03.2016 / 15:50
source