Can't figure this out, perhaps someone could help me?
I'm trying to compare a number to the first record in a sorted iqueryable of numbers. The problem is my query is being returned as an iqueryable of numbers, so I can't compare the 2 (a decimal with an iqueryable<decimal>). How do I break the iqueryable down into a single object? I thought [.Take1] would do it but obviously that just gives you an iqueryable with 1 record.
Here's my code (probably horrible for more experienced eyes!)
IndividualPrice.Total is a decimal. I'm an amateur so if there's a better way to do what I'm trying please let me know.
I'm trying to compare a number to the first record in a sorted iqueryable of numbers. The problem is my query is being returned as an iqueryable of numbers, so I can't compare the 2 (a decimal with an iqueryable<decimal>). How do I break the iqueryable down into a single object? I thought [.Take1] would do it but obviously that just gives you an iqueryable with 1 record.
Here's my code (probably horrible for more experienced eyes!)
PHP:
if (IndividualPrice.Total == (from HighestPrice in Model.retailersProducts.Where(x => x.ProductId == product.ProductId) orderby HighestPrice.Total descending select HighestPrice.Total).Take(1))
IndividualPrice.Total is a decimal. I'm an amateur so if there's a better way to do what I'm trying please let me know.