LINQ query to select top five

后端 未结 6 1195
轻奢々
轻奢々 2020-12-02 05:46

I have a LINQ query:

var list = from t in ctn.Items
           where t.DeliverySelection == true && t.Delivery.SentForDelivery == null
           ord         


        
6条回答
  •  遥遥无期
    2020-12-02 06:32

    Just thinking you might be feel unfamiliar of the sequence From->Where->Select, as in sql script, it is like Select->From->Where.

    But you may not know that inside Sql Engine, it is also parse in the sequence of 'From->Where->Select', To validate it, you can try a simple script

    select id as i from table where i=3
    

    and it will not work, the reason is engine will parse Where before Select, so it won't know alias i in the where. To make this work, you can try

    select * from (select id as i from table) as t where i = 3
    

提交回复
热议问题