में नहीं किया जा सकता है मुझे एमवीसी के साथ क्वेरी में शामिल होने में कोई समस्या है और मुझे नहीं पता कि क्यों।त्रुटि: इकाई या जटिल प्रकार का निर्माण LINQ से Entities क्वेरी
The entity or complex type 'Tusofona_Website.Models.site_noticias' cannot be constructed in a LINQ to Entities query.
मेरे नियंत्रक:
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);
}
मेरे मॉडल:
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; }
}
किसी को भी मेरी मदद कर सकते?
संभावित डुप्लिकेट [इकाई संस्थाओं के लिए एक LINQ का निर्माण नहीं किया जा सकता क्वेरी] (http://stackoverflow.com/questions/5325797/the-entity-cannot-be-constructed-in-a- linq-to-entities-query) –