Błąd: encji lub typu złożonego nie można skonstruować w zapytaniu LINQ to Entities
Mam problem z połączeniem zapytania z MVC i nie wiem dlaczego.
Jednostki lub typu złożonego „Tusofona_Website.Models.site_noticias” nie można skonstruować w zapytaniu LINQ to Entities.
Mój kontroler:
private TusofonaDBs db = new TusofonaDBs();
//
// GET: /DestaquesMain/
public ActionResult Index()
{
var query = (from sd in db.site_desquesnoticias
join sn in db.site_noticias on sd.IDNoticia equals sn.IDNoticia
where sn.Destaque == 1
select new site_noticias {
CorpoNoticia = sn.CorpoNoticia,
TituloNoticia = sn.TituloNoticia
}).ToList();
//return View(db.site_desquesnoticias.ToList());
return View(query);
}
Mój model:
public class site_destaquesnoticias
{
[Key]
public Int32 IDDestaque { get; set; }
public Int32 IDNoticia { get; set; }
public string Foto { get; set; }
}
public class site_noticias
{
[Key]
public Int32 IDNoticia { get; set; }
public string CorpoNoticia { get; set; }
public string TituloNoticia { get; set; }
public string Foto { get; set; }
public Int32 Destaque { get; set; }
}
public class TusofonaDBs : DbContext
{
public DbSet<site_destaquesnoticias> site_desquesnoticias { get; set; }
public DbSet<site_noticias> site_noticias { get; set; }
}
Czy ktoś może mi pomóc?