LINQ subquery IN

后端 未结 4 2014
星月不相逢
星月不相逢 2021-01-02 15:01

I\'m a newbie with the IQueryable, lambda expressions, and LINQ in general. I would like to put a subquery in a where clause like this :

Sample code :



        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-02 15:38

    Same example with Linq method syntax:

    var innerquery =  dbcontext.DataDictVal                  
                     .where(x=> x.TbiTableName == myTableNameVariable
                        && x.DdColumnName == "Status"
                        && x.DdbColumnValLangDsc1.StartsWith("ac"))
                     .select(x=>x.DdvColumnVal)
    
    var query = dbcontext.Client
                .where( c=>innerquery.Contains(c.Etat))
    

    Note:

    Am providing this answer, because when i searched for the answer, i couldn’t find much answer which explains same concept in the method syntax.

    So In future, It may be useful for the people, those who intestinally searched method syntax like me today. Thanks karthik

提交回复
热议问题