Give preference to the results that have the parameter passed in the Entity Framework [duplicate]

1

I'm trying to implement a data solution that first displays the values that have the passed parameter and then pass the other parameters.

Example:

In a product table you have the following data:

Coca-Cola  -> Coca Cola Company
Pepsi      -> Pepsico
Toddy      -> Pepsico
Dolly      -> Dolly
Itubaina   -> Schin

When I pass the pepsico manufacturer parameter in the entity framework it should display the values in the following order:

Pepsi      -> Pepsico
Toddy      -> Pepsico
Coca-Cola  -> Coca Cola Company
Dolly      -> Dolly
Itubaina   -> Schin

How can I do this?

    
asked by anonymous 28.03.2016 / 15:04

1 answer

2

You can do it this way:

var result = Produtos.OrderByDescending(e => e.Fabricante.Contains("Pepsico"));
    
28.03.2016 / 15:26