开发者

Using Linqpad for a simple query

开发者 https://www.devze.com 2023-01-24 05:21 出处:网络
This works within visual studio: PeliculasEntities db = new PeliculasEntities(); DetalleAlquiler detalleAlquiler = (DetalleAlquiler)db.DetalleAlquilers.FirstOrDefault(x => x.ID == 1);

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?

Using Linqpad for a simple query


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)

0

精彩评论

暂无评论...
验证码 换一张
取 消