How do I get the individual values from the following LINQ query? (I want to get the value for DecalExpireDate, DecalExpireMonth, and DecalExpireYear.)
var previousExpirationDate = (from d in db.CT_Decals
where d.TankID == decal.TankID
&& d.DecalStatus == "Approved"
select new
{
d.DecalExpireDate,
d.DecalExpireMonth,
d.DecalExpireYear
}).Max(d => d.DecalExpireDate);
I assume you want to get the DecalExpireDate
, DecalExpireMonth
, and DecalExpireYear
from the element with the highest (last) DecalExpireDate
. Then you could order by this date:
var latest = (from d in db.CT_Decals
where d.TankID == decal.TankID && d.DecalStatus == "Approved"
orderby d.DecalExpireDate descending
select new
{
d.DecalExpireDate,
d.DecalExpireMonth,
d.DecalExpireYear
}).First();
var decalExpireDate = latest.DecalExpireDate;
var decalExpireMonth = latest.DecalExpireMonth;
var decalExpireYear = latest.DecalExpireYear;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With