convert IQueryable to

前端 未结 6 792
滥情空心
滥情空心 2020-12-16 18:01

I want to select my price level in database to compare with the an integer number. But It is error : Operator \'==\' cannot be applied to operands of type \'System.Linq.IQue

6条回答
  •  温柔的废话
    2020-12-16 18:41

    That's the beauty of Linq that every query returns an IQueryable so you can defer getting the final result until you really decided what you want. On the other word you can execute a query over another query :) So in order to get the real data out of a query you should execute a command over it that actually returns what you want. In your case since you are expecting your query to return only one value any methods like "FirstOrDefault","Single" or "First" will do the trick

提交回复
热议问题