Using Linqpad for a simple query
This works within visual studio:
PeliculasEntities db = new PeliculasEntities();
DetalleAlquiler detalleAlquiler = (DetalleAlquiler)db.DetalleAlquilers.FirstOrDefault(x => x.ID == 1);
MessageBox.Show(detalleAlquiler.Alquiler.Cliente.Natural.Edad.ToString());
I want to retrive the same information inside of LinqPad. Any help?
When I run this I get an error: "DetalleAlquiler does not have a definition for aAquiler"
var detalle开发者_运维技巧 = DetalleAlquilers.Where(x => x.ID == 1);
var edad = detalle.Alquiler.Cliente.Natural.Edad.ToString();
What variable do I use to access the database?
Change Language to C# Expression.
You are forgetting to call FirstOrDefault()
on your first line so 'detalle' is an IEnumerable<DetailleAlquiler>
and not a DetailleAlquiler
Try:
var detalle = DetalleAlquilers.FirstOrDefault(x => x.ID == 1);
var edad = detalle.Alquiler.Cliente.Natural.Edad.ToString();
Which is actually what you had, originally, in VS. (Don't forget to add edad.Dump();
if you actually want to see the results)
精彩评论