0

in my system user choose start time and end time and then my system show user sum of total prices between this date time.

 TotalRate = room.Prices.Where( hrp => hrp.ValidStartAt<= hotelSearchModel.StartAt.Value &&
  hrp.ValidEndAt >= hotelSearchModel.StartAt.Value).Sum(p => p.NightPriceRate), 

i want to debug this but it says Expression cannot contain lambda expressions how can i debug this and what is my mistake with this code?

user1688401
  • 1,851
  • 8
  • 47
  • 83
  • Are you sure this line has error ? It seems haven't any problem. – Mojtaba May 26 '13 at 10:23
  • 1
    When you say "I want to debug this", are you trying that in the Immediate\Watchs windows? If so, be aware that lamdas are not allowed there, see http://stackoverflow.com/questions/725499/vs-debugging-quick-watch-tool-and-lambda-expressions – Daniel J.G. May 26 '13 at 11:32
  • _what is my mistake_ Well, what happens? Unexpected results? Exception? – Gert Arnold May 26 '13 at 18:12
  • no exception unexpected results.it sum but ressult is wrong – user1688401 May 27 '13 at 07:58
  • A great place to start is to include a line of debug code that shows you what your result set looks like before you sum it up: `var prices = room.Prices.Where( hrp => hrp.ValidStartAt<= hotelSearchModel.StartAt.Value && hrp.ValidEndAt >= hotelSearchModel.StartAt.Value);` – Brad Rem May 27 '13 at 17:54

1 Answers1

0

Unfortunatelly Visual Studio does not support LINQ in Expressions but for such not complicated queries http://www.linqpad.net/ probably can be usefull.

Hope it will help.

Mitchel
  • 11
  • 2