2
I need help in defining the correct class statement
Follows my code:
public void BuscaOcorremcias()
{
//Op 01 - Declarando um IList da Model
IList<Ocorrencia> ocorrencias = null;
//Op 02 - Declarando um DbSet
System.Data.Entity.DbSet<MoradaWeb.Models.Ocorrencia> ocorrencias = null;
ocorrencias = db.Ocorrencia.Include("Pessoa").Where(c => c.status == true);
if (MinhaRegradeNegocio)
ocorrencias = ocorrencias.Where(c => c.Pessoa == PessoaLogada);
}
//My Context
public class MeuContext : DbContext
{
public MoradaWebContext() : base("name=MinhaConnectionString")
{ ... }
public System.Data.Entity.DbSet<Models.Ocorrencia> Ocorrencia { get; set; }
}
The error that occurs with the above two options (in the code comment) is this:
Cannot implicititly Convert type...
I’m not sure what kind to declare so I can maintain the condition of applying an extra Where if I have to. In this case I want to make the second Where inside the collection itself that has already been searched in the bank.
State as
var ocorrencias = db.Ocorrencia.Include("Pessoa").Where(c => c.status == true);
and see the type defined by placing the mouse cursor over the variable occurrences.– Ismael