Select method is not called using LinQ query syntax

前端 未结 3 1849
一个人的身影
一个人的身影 2021-01-20 01:53

I want to enable LinQ query syntax over my classes. I think query syntax is translated to method syntax, for example:

var query = from p in new Class1

        
3条回答
  •  萌比男神i
    2021-01-20 02:12

    Your understanding is little incorrect, the following query :

    var query = from p in new Class1()
            where p.Id == "1000"
            select p
    

    will translate to :

    var query = new Class1().Where(p => p.Id == "1000");
    

    and when you are removing the where part:

    var query = from p in new Class1()
                select p;
    

    now it will be translated to something like:

    var query = new Class1().Select(p=>p);
    

提交回复
热议问题